Created
December 3, 2015 14:51
-
-
Save aNd1coder/fffe726d68c94c142ad8 to your computer and use it in GitHub Desktop.
配置ssh密钥快速登录远程服务器
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 1.生成密钥 | |
ssh-keygen -t rsa | |
# 2.拷贝公钥id_rsa.pub到远程服务器的用户.ssh目录下(这里远程服务器是Mac OSX) | |
scp ~/.ssh/id_rsa.pub {remote_username}@{remote_ip}:~/{remote_username}/.ssh/ | |
# 3.重命名远程服务器上的id_rsa.pub为authorized_keys | |
mv id_rsa.pub authorized_keys | |
# 4.编辑本地配置文件 | |
vim ~/.ssh/config | |
# 5.输入如下命令并保存 | |
Host {alias} | |
Hostname {remote_ip} | |
Port 22 | |
User {local_username} | |
IdentityFile ~/.ssh/id_rsa | |
# 5.这样就可以通过ssh {alias}来快速登录远程服务器而不需要每次都输入密码了 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment