ssh自动登入
步骤如下:
1.在客户端建立一个公匙和私匙
ssh-keygen -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/home/test2/.ssh/id_rsa): <==按下Enter
Enter passphrase (empty for no passphrase): <按 Enter
Enter same passphrase again: <再按一次 Enter
Your identification has been saved in /home/test2/.ssh/id_rsa. <==私匙
Your public key has been saved in /home/test2/.ssh/id_rsa.pub. <==公匙
The key fingerprint is:
c4:ae:d9:02:d1:ba:06:5d:07:e6:92:e6:6a:c8:14:ba
# 注意: -t 指的是如种加密方式RSA ,
[test2@test2 ~]$ ll ~/.ssh
total 12
-rw------- 1 test test 887 Nov 12 22:36 id_rsa
-rw-r--r-- 1 test test 233 Nov 12 22:36 id_rsa.pub
-rw-r--r-- 1 test test 222 Oct 31 11:20 known_hosts
注意 我们在这里使用的test这个用户
2.在客户端放私匙 cp id_rsa ~/.ssh
3.在服务器端放入公匙scp id_rsa.pub
test@服务器:~/中
4.修改/etc/ssh/sshd_config 文件
将
#AuthorizedKeysFile .ssh/authorized_keys
改为
AuthorizedKeysFile .ssh/authorized_keys
5.重启SSHD 试一试就OK了
步骤如下:
1.在客户端建立一个公匙和私匙
ssh-keygen -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/home/test2/.ssh/id_rsa): <==按下Enter
Enter passphrase (empty for no passphrase): <按 Enter
Enter same passphrase again: <再按一次 Enter
Your identification has been saved in /home/test2/.ssh/id_rsa. <==私匙
Your public key has been saved in /home/test2/.ssh/id_rsa.pub. <==公匙
The key fingerprint is:
c4:ae:d9:02:d1:ba:06:5d:07:e6:92:e6:6a:c8:14:ba
# 注意: -t 指的是如种加密方式RSA ,
[test2@test2 ~]$ ll ~/.ssh
total 12
-rw------- 1 test test 887 Nov 12 22:36 id_rsa
-rw-r--r-- 1 test test 233 Nov 12 22:36 id_rsa.pub
-rw-r--r-- 1 test test 222 Oct 31 11:20 known_hosts
注意 我们在这里使用的test这个用户
2.在客户端放私匙 cp id_rsa ~/.ssh
3.在服务器端放入公匙scp id_rsa.pub
test@服务器:~/中
4.修改/etc/ssh/sshd_config 文件
将
#AuthorizedKeysFile .ssh/authorized_keys
改为
AuthorizedKeysFile .ssh/authorized_keys
5.重启SSHD 试一试就OK了
阅读(759) | 评论(0) | 转发(0) |