ssh免密码登录

Linux 为例方便ssh登录,避免交互输入密码,可以简单配置ssh互信来完成

192.168.2.9 本地主机       192.168.2.109 远程主机  

在2.9上执行的命令: 一路回车敲下去
[[email protected] ~]# 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:
f6:51:47:62:dc:3f:d4:df:1e:85:87:96:7b:58:29:ea [email protected]


[[email protected] ~]#  ssh [email protected] "mkdir .ssh;chmod 0700 .ssh" 
[email protected]'s password:(需要输入密码) 

[[email protected] ~]# scp ~/.ssh/id_rsa.pub [email protected]:.ssh/id_rsa.pub 
[email protected]'s password:(需要输入密码) 在2.109上的命令: 

[[email protected]~]# touch /root/.ssh/authorized_keys 
[[email protected]~]# <# cat /root/.ssh/id_rsa.pub >> /root/.ssh/authorized_keys2 (将id_rsa.pub的内容追加到 authorized_keys 中) 

在2.9 ssh 登陆测试: # ssh [email protected] (不需要密码, 登录成功)

你可能感兴趣的:(linux,测试,ssh,File)