Linux设置SSH不输入密码登陆方式

Linux · andrew · 于 1年前发布 · 2266 次阅读

--设置ssh不输入密码的方式登陆

在本服务器生成登录密钥

[root@officalweb1 bin]# 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:a3:fd:b1:e2:5e:2e:73:5b:fa:3e:ee:3a:e9:13:cc root@officalweb1.s1.wcc.cc

[root@officalweb1 ~]# cat /root/.ssh/id_rsa.pub
ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAv5+Ct8CwHYSg/wLZLKktqM+vo7PXD8+xOLOcCpI6uGOBVooPzGyOLD54jYQBkgqhUpRD2ulZ9WcdRjFAhzxwQiR86MUffavtCHBN2LeiOay8iJTmCdZQ3SdmUwD2VYFft3kBGzyZF/2N/ecg0Hyz6Kl6IjAyL9lQCPesab2AXeMJLPGSZarmLZw4VxhOdwVjDW82IcGGVOBN9ZjmSY9y7AlrDRhdsSzrNgUHLwjVo0gYzZVSflR6ZQmICOV9IvPAK7WFyh9c/LQ2s8PXNUpxOrugDAI5Wm9+ldKuKLHKTnUC//hpU3LEFZiIELxsHrKE+gSCwIQWlAApHBOfLwiLwQ== root@officalweb1.s1.wcc.cc

将登录服务器id_rsa.pub文件拷到被登录服务器

[root@officalweb1 .ssh]# scp id_rsa.pub wade.ru@172.21.8.1:~/.ssh/

被登录服务器里将拷过来的id_rsa.pub 重命名为 authorized_keys,放在~/.ssh/目录下

[wade.ru@proxy1 .ssh]$ cd ~/.ssh/
[wade.ru@proxy1 .ssh]$ mv id_rsa.pub authorized_keys

测试,登录成功

[root@officalweb1 .ssh]# ssh wade.ru@172.21.8.1
Last login: Tue Aug 14 17:11:21 2012 from 172.21.108.1
[wade.ru@proxy1 ~]$

共收到 0 条回复 linux
没有找到数据。
回复本帖 (需要登录)