13

ssh利用RSA公钥远程登录验证

 3 years ago
source link: http://abcdxyzk.github.io/blog/2013/03/12/tools-ssh-rsa/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

ssh利用RSA公钥远程登录验证

2013-03-12 11:54:00

1、本地机器生成密钥
$ssh-keygen -t rsa

生成基于ssh协议第二版密钥,如果还是用rsa1,该升级了。

2、复制生成的id_rsa.pub公钥文件到远程服务器,简单的用:
$scp id_rsa.pub [email protected]:mykey.pub
3、密码登陆远程服务器:
$ssh 192.168.1.188 -l bsduser

这里注意不是cp,而是cat;不是">“,而是”>>“的操作:

%cat mykey.pub >> $HOME/.ssh/authorized_keys
4、重启sshd
#/etc/rc.d/sshd restart
5、此时进行登录测试:

成功,则可以不用输入繁琐和易泄露的密码。但是条件是你要保护好自己的密钥文件信息。

  • 注意authorized_keys文件权限设置600

  • 服务器上若对用户主目录进行了软链接,则软链接的目录权限要小等于755。如 ln -s /opt/kk /home/kk, 则需要chmod 755 /opt/kk,不然会不起作用。


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK