您的位置:首页 > 其它

设定没有密码的SSH访问方式

2009-09-02 14:32 204 查看
local> ssh-keygen -t dsa -f .ssh/id_dsa

-t tells the type of encription
-f tells where to store the public/private key pairs. In this case, the .ssh directory on home is being used

A password will be asked; leave this part blank, just pressing <enter>
Now, go the .ssh directory, and you will find two new files: id_dsa and id_dsa.pub. The last one is the public part. Now, copy the public key to the server machine

local> cd .ssh
local> scp id_dsa.pub user@remote:~/.ssh/id_dsa.pub

Of course, this time you will need to enter the password.
Now, login into the server machine and go to the .ssh directory on the server side

local> ssh user@remote
remote> cd .ssh

Now, add the client's public key to the know public keys on the server

remote> cat id_dsa.pub >> authorized_keys2
remote> chmod 640 authorized_keys2
remote> rm id_dsa.pub

remote> exit

and that's all.
Next time you log into the remote server, no password will be asked.



---------------------------------------------------------------------------------------------------------------------------------------

Sample:



local> ssh-keygen -t dsa -f .ssh/id_dsa
-t tells the type of encription
-f tells where to store the public/private key pairs. In this case, the .ssh directory on home is being used
A password will be asked; leave this part blank, just pressing <enter>
Now, go the .ssh directory, and you will find two new files: id_dsa and id_dsa.pub. The last one is the public part. Now, copy the public key to the server machine
local> cd .ssh
local> scp id_dsa.pub root@xxx.xxx.xxx.xxx:~/.ssh/id_dsa.pub
Of course, this time you will need to enter the password.
Now, login into the server machine and go to the .ssh directory on the server side
local> ssh root@xxx.xxx.xxx.xxx
remote> cd .ssh
Now, add the client's public key to the know public keys on the server
remote> cat id_dsa.pub >> authorized_keys2
remote> chmod 640 authorized_keys2
remote> rm id_dsa.pub
remote> exit
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: