在工做中常常須要使用不一樣的私鑰登陸不一樣的服務器,遂須要對不一樣的私鑰進行管理git
首先,在新增私鑰的時候須要經過不一樣的文件名來生成不一樣的私鑰文件github
ssh-keygen -t rsa -f ~/.ssh/id_rsa.work -C "key for work" ssh-keygen -t rsa -f ~/.ssh/id_rsa.github -C "key for github"
新增ssh配置文件,並修改權限服務器
touch ~/.ssh/config chmod 600 ~/.ssh/config
編輯配置文件dom
vi ~/.ssh/config
Host *.workdomain.com HostName *.workdomain.com IdentityFile ~/.ssh/id_rsa.work Host github.com HostName github.com User git IdentityFile ~/.ssh/id_rsa.github
登陸ssh
ssh root@www.workdomain.com
或code
ssh github.com