原创

免密码登录(ssh远程客户端)

通过命令”ssh-keygen -t rsa“

通过命令”ssh-keygen -t rsa“
Generating public/private rsa key pair.
Enter file in which to save the key (/root/.ssh/id_rsa):  回车
Enter passphrase (empty for no passphrase):               回车
Enter same passphrase again:                              回车
Your identification has been saved in /root/.ssh/id_rsa.
Your public key has been saved in /root/.ssh/id_rsa.pub.
The key fingerprint is:
40:98:85:aa:90:b9:ed:3e:d7:44:ee:75:4a:0e:21:d7 root@VM-29cad895-11da-49b7-a970-27c763f52c29
The key's randomart image is:
+--[ RSA 2048]----+
|     =o          |
|    +.            |
| o .  ..          |
|+ . . +.E        |
|.+   = .S        |
|o .   + o .      |
| .   + = o       |
|  o . o o        |
| ..o             |
+-----------------+

生成之后会在用户的根目录生成一个 “.ssh”的文件夹

进入/root/.ssh/会生成以下几个文件
  authorized_keys:存放远程免密登录的公钥,主要通过这个文件记录多台机器的公钥  
  id_rsa : 生成的私钥文件
  id_rsa.pub : 生成的公钥文件
  know_hosts : 已知的主机公钥清单

#复制公钥id_rsa.pub到172.16.0.3 的当前用户的.ssh目录下,同时输入172.16.0.3的root密码(本机)
ssh-copy-id -i ~/.ssh/id_rsa.pub 172.16.0.3

scp -p ~/.ssh/id_rsa.pub root@登录端IP:/root/.ssh/authorized_keys 

-bash: ssh-copy-id: command not found //提示命令不存在
解决办法:yum -y install openssh-clients

正文到此结束
本文目录