现在我在阿里云购买了一台云服务器,其 ip 地址为 120.27.210.94,我在自己电脑上,用 SSH 登录远程主机。
1 2 3 4
➜ ~ ssh root@120.27.210.94 The authenticity of host '120.27.210.94 (120.27.210.94)' can't be established. ECDSA key fingerprint is SHA256:+FvnAMcSHUPuWvciMpQhvlZaITKUg9gJa/nqAyg7G/s. Are you sure you want to continue connecting (yes/no)?
Are you sure you want to continue connecting (yes/no)? yes Warning: Permanently added '120.27.210.94' (ECDSA) to the list of known hosts. root@120.27.210.94's password: ... Welcome to Alibaba Cloud Elastic Compute Service !
➜ ~ ssh-keygen Generating public/private rsa key pair. Enter file in which to save the key (/Users/mjd/.ssh/id_rsa): Enter passphrase (empty for no passphrase): Enter same passphrase again: Your identification has been saved in /Users/mjd/.ssh/id_rsa. Your public key has been saved in /Users/mjd/.ssh/id_rsa.pub. The key fingerprint is: SHA256:eioQgRNeYDEoGXJ6tXY6uonHPUxT8PhE9KjJmC7GAgY mjd@mjddeMacBook-Pro.local The key's randomart image is: +---[RSA 2048]----+ |=X+.... | |Xo+....o | |Eo..o=o . | |...=.=+ | |..o.*+ S | |+...o... | |o+o= .. . | |oooo= o | |..o o. | +----[SHA256]-----+
现在,两个密钥文件被创建出来了:「id_rsa.pub」(公钥) 和 「id_rsa」(私钥)。如果是 Mac,可以在你 home 目录下的「.ssh」 目录中找到它们(~./ssh/)。
➜ ~ ssh-copy-id root@120.27.210.94 /usr/bin/ssh-copy-id: INFO: Source of key(s) to be installed: "/Users/mjd/.ssh/id_rsa.pub" /usr/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed /usr/bin/ssh-copy-id: INFO: 1 key(s) remain to be installed -- if you are prompted now it is to install the new keys root@120.27.210.94's password:
Number of key(s) added: 1
Now try logging into the machine, with: "ssh 'root@120.27.210.94'" and check to make sure that only the key(s) you wanted were added.
Copyright Declaration: This station is mainly used to sort out incomprehensible knowledge. I have not fully mastered most of the content. Please refer carefully.