Git configure multiple servers

mkdir -p ~/.ssh

cd ~/.ssh/
ssh-keygen -t rsa -C "[email protected]" # Name the file id_rsa_xiaomi and press Enter all the way
ssh-keygen -t rsa -C "[email protected]" # Name this file id_rsa_github, and press Enter all the way

# At this point, two pairs of public and private keys are generated under ~/.ssh

touch config
chmod 600 ~/.ssh/*

Add the following to #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 paste the content of xiaomi's ssh keys
# cat ~/.ssh/id_rsa_github.pub paste the content of github's ssh keys

 

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326697936&siteId=291194637