多语言展示
当前在线:351今日阅读:82今日分享:28

ssh免密登录简单实现

linux运维中有时候需要免密登陆另一个linux,这个时候就需要了
工具/原料

已经安装好的2台linux

方法/步骤
1

假设有两台服务器 server(192.168.16.10) 和client(192.168.16.11),现在需要client可以免密登陆server.

2

在服务器client上创建密钥(命令运行中一路回车即可)[root@client ~]# ssh-keygen -t rsaGenerating 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:b7:01:7d:f7:51:73:c4:f2:3c:6c:61:fa:ae:f9:d6:ea root@clientThe key's randomart image is:+--[ RSA 2048]----+|               ++||         .    .o=||        . . . ==.||         . . o =+||        S o   o o||         . o   . ||          .   . .||              .o.||             +Eo |+-----------------+

3

在服务器server上加入密钥(过程中选yes并输入client的密码一次)[root@server ~]# ssh client cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keysThe authenticity of host 'client (192.168.16.11)' can't be established.RSA key fingerprint is 8d:88:19:2d:a9:15:e1:f6:3e:c9:0e:48:53:cf:8c:f7.Are you sure you want to continue connecting (yes/no)? yesWarning: Permanently added 'client ' (RSA) to the list of known hosts.root@client 's password:

4

在服务器client上验证登陆server(成功)[root@client ~]# ssh serverLast login: Sat Apr 15 08:40:18 2017 from client

推荐信息