不用密码登录SSH(PUTTY)
一、生成密码对
ssh-keygen -t rsa -f ~/.ssh/id_rsa
会提示输入密码,可留空。
会生成
私有密钥: ~/.ssh/id_rsa.
公有密钥: ~/.ssh/id_rsa.pub.
二、授权
把生成的公有密钥放到被链主机的~/.ssh/authorized_keys文件中
cat .ssh/id_rsa.pub | ssh b@B ‘cat >> .ssh/authorized_keys’
三、登录
ssh b@B hostname
四、PUTTY登录
需要把私有密钥生成PUTTY的格式。打开PUTTY KEY GENERATURE,导入私有密钥,保存。会生成xxx.ppt文件。
在Connection->SSH->Auth中引入xxx.ppt文件。
在Connection->Data中输入用户名。
保存。
五、注意保护密钥
给~/.ssh目录和文件改权限。
A note from one of our readers: Depending on your version of SSH you might also have to do the following changes:
Put the public key in .ssh/authorized_keys2
Change the permissions of .ssh to 700
Change the permissions of .ssh/authorized_keys2 to 640
Leave a comment