Linux Server Deployment(IV)SSH private/public key
1. generate the public/private keys for SSH on local server
>ssh-keygen -t rsa
Enter file in which to save the key():
Enter passphrase(empty for no passphrase):
Enter same passphrase again:
You identification has been saved in /home/username/.ssh/id_rsa.
You public key has been saved in /home/chengdu/.ssh/id_rsa.pub.
2. remote server and configuration
copy the keys from id_rsa.pub to remote server ~/.ssh/
>scp id_rsa.pub username@server.com:~/.ssh/
logon the remote server
>ssh username@server.com
put the public key in file authorized_keys
>cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys
change the authority
>chmod 711 ~/.ssh
>chmod 644 ~/.ssh/authorized_keys
3. Success
>ssh username@server.com
I do not need to type password again.
references:
http://bbs.chinaunix.net/viewthread.php?tid=111248
http://shutiao2008.iteye.com/blog/315102
http://lhflinux.blog.51cto.com/1961662/526122
http://www.josephj.com/article/understand-ssh-key/
1. generate the public/private keys for SSH on local server
>ssh-keygen -t rsa
Enter file in which to save the key():
Enter passphrase(empty for no passphrase):
Enter same passphrase again:
You identification has been saved in /home/username/.ssh/id_rsa.
You public key has been saved in /home/chengdu/.ssh/id_rsa.pub.
2. remote server and configuration
copy the keys from id_rsa.pub to remote server ~/.ssh/
>scp id_rsa.pub username@server.com:~/.ssh/
logon the remote server
>ssh username@server.com
put the public key in file authorized_keys
>cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys
change the authority
>chmod 711 ~/.ssh
>chmod 644 ~/.ssh/authorized_keys
3. Success
>ssh username@server.com
I do not need to type password again.
references:
http://bbs.chinaunix.net/viewthread.php?tid=111248
http://shutiao2008.iteye.com/blog/315102
http://lhflinux.blog.51cto.com/1961662/526122
http://www.josephj.com/article/understand-ssh-key/
本文介绍如何在本地服务器上生成SSH公钥/私钥,并将公钥复制到远程服务器以实现免密码登录。主要内容包括:1. 生成SSH密钥对;2. 复制公钥到远程服务器;3. 设置远程服务器上的授权密钥文件;4. 验证配置是否成功。
1万+

被折叠的 条评论
为什么被折叠?



