Git配置多个服务器

JackJay的技术 2014-03-28

mkdir -p ~/.ssh

cd ~/.ssh/
ssh-keygen -t rsa -C "xx@xiaomi.com" # 把这个文件命名为id_rsa_xiaomi,然后一路回车
ssh-keygen -t rsa -C "yy@163.com" # 把这个文件命名为id_rsa_github,然后一路回车

# 此时在~/.ssh下面生成两对公私钥

touch config
chmod 600 ~/.ssh/*

#config中添加下面内容:
host git.n.xiaomi.com
user git
hostname git.n.xiaomi.com
port 22
identityfile ~/.ssh/id_rsa_xiaomi

host github.com
user git
hostname github.com
port 22
identityfile ~/.ssh/id_rsa_github

# cat ~/.ssh/id_rsa_xiaomi.pub的内容贴到xiaomi的ssh keys中
# cat ~/.ssh/id_rsa_github.pub的内容贴到github的ssh keys中

相关推荐