The followings are the steps to set up SSH automatically authentication:
3.1 Generate Public/private key pair in clients that need SSH/SCP access using public key under particular user id, such as root or josss,etc. to a remote server as shown in the following steps:
# su
The following commands need to run under the user account that will use public key authentication, such as root or josss, etc.
# cd $HOME/.ssh
# ssh-keygen -t rsa -f $HOME/.ssh/identity -N ""
Generating public/private rsa key pair.
Your identification has been saved in /root/.ssh/identity.
Your public key has been saved in /root/.ssh/identity.pub.
The key fingerprint is:
37:39:bd:e8:de:de:33:85:32:74:4f:33:42:01:bf:dc root@openssl-ssh
3.2 Upload public key into remote server’s the same user id’s, such as root’s or josss’s, $HOME/.ssh directory . These commands need to run under the user account that will use public key authentication, such as root or josss,etc.
# scp –P 333 identity.pub (remote server name or IP address):/$HOME/.ssh/authorized_keys.01
For examples:
# scp –P 333 identity.pub 172.16.242.32:/$HOME/.ssh/authorized_keys.01
The authenticity of host '172.16.242.32 (172.16.242.32)' can't be established.
RSA key fingerprint is fd:be:a6:44:b8:7e:c1:4e:a5:11:3f:c9:d9:ac:eb:04.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '172.16.242.32' (RSA) to the list of known hosts.
root@172.16.242.32's password:
identity.pub 100% 226 0.2KB/s 00:00
If root or josss user ID cannot be used for the above step, please use your own account.
Log into the remote server and run the following command under the user account that will use public authentication:
#cat /root/.ssh/authorized_keys.01 >> $HOME/.ssh/authorized_keys
3.3 In the client, run the following command and make sure there is NO password being asked this time; If so, SSH automatically authentication set up successfully.
# scp –P 333 identity.pub (remote server name or IP address):/$HOME/.ssh/authorized_keys.test
For examples:
# scp –P 333 identity.pub 172.16.242.32:/$HOME/.ssh/authorized_keys.test
identity.pub 100% 226 0.2KB/s 00:00
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/223555/viewspace-503012/,如需转载,请注明出处,否则将追究法律责任。
转载于:http://blog.itpub.net/223555/viewspace-503012/