同时配置多个SSH

29 阅读1分钟
  • 命令行
cd ~/.ssh 
ls
ssh-keygen -t rsa -C '2567199685@qq.com' -f  ~/.ssh/github_id_rsa  // 生成密钥
touch config // 创建config
vim config // 配置config
cat github_id_rsa.pub // 获取生成的密钥,并到git中配置(pub是公共密钥的意思)
  • config 配置
# codeup
Host codeup
HostName codeup.aliyun.com
IdentityFile ~/neware.com.cn/.ssh/erp_rsa.pub
PreferredAuthentications publickey
IdentityAgent none
IdentitiesOnly yes

# neware
Host neware
HostName git.neware.work:8027
IdentityFile ~/neware.com.cn/.ssh/git_neware_work.pub
PreferredAuthentications publickey
IdentityAgent none
IdentitiesOnly yes

# github
Host github
HostName github.com
IdentityFile ~/.ssh/github_id_rsa
PreferredAuthentications publickey
IdentityAgent none
IdentitiesOnly yes