ssh链接:
ssh root@192.168.1.250
ssh -p 22222 root@101.201.43.143
输入密码登陆
ssh不用收入密码建立密钥
1、生成秘钥
[root@localhost logs]# ssh-keygen
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:
6b:45:21:25:cf:b2:0d:ac:cd:28:d6:1a:a2:32:82:41 root@localhost.localdomain
The key‘s randomart image is:
+--[ RSA 2048]----+
| o.o |
| . = . |
| E + + |
|. . = * |
|. . + + S o |
|.o o + o |
|* . o |
|o. . |
| |
+-----------------+
2、22号端口把秘钥发过去
[root@localhost logs]# ssh-copy-id -i ~/.ssh/id_rsa.pub root@192.168.1.250
root@192.168.1.250‘s password:
3、非22号端口把秘钥发过去
[root@localhost logs]# ssh-copy-id -i ~/.ssh/id_rsa.pub ‘-p 22222 root@101.201.43.143‘
root@101.201.43.143‘s password:
下次链接不用收入密码了!
原文地址:http://12927979.blog.51cto.com/12917979/1951129