Git配置多个服务器

mkdir -p ~/.ssh

cd ~/.ssh/
ssh-keygen -t rsa -C "[email protected]" # 把这个文件命名为id_rsa_xiaomi,然后一路回车
ssh-keygen -t rsa -C "[email protected]" # 把这个文件命名为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中

猜你喜欢

转载自qxh.iteye.com/blog/2038078