root:~ root$ ls -a
. .gitignore_global Desktop
.. .hgignore_global Documents
.CFUserTextEncoding .local Downloads
.CocosCreator .mailcap Library
.DS_Store .mime.types Movies
.Trash .oss-browser Music
.bash_history .ssh Pictures
.bash_profile .subversion Public
.bash_sessions .vim Applications
- 进入”.ssh”目录
cd .ssh
- 将密钥文件复制到此目录中
root:.ssh root$ cp /Users/wenle/Desktop/guoke.pem ./
- 编辑”config”文件,并输入以下内容
vim config
Host guoke
HostName 192.168.1.55
User root
IdentityFile ~/.ssh/guoke.pem
- Host 自定义名
- HostName 连接的IP
- User 登陆用户名
- IdentityFile 密钥文件
- 连接
直接ssh + 配置中Host中自定义名
root:.ssh root$ ssh guoke
- 如果配置多个服务器中,直接服务一次这个配置就行了
Host guoke
HostName 192.168.1.55
User root
IdentityFile ~/.ssh/guoke.pem
Host guoke1
HostName 192.168.1.56
User root
IdentityFile ~/.ssh/guoke.pem