# Git 设置多个 SSH Key **Published by:** [cryptoshine.eth](https://paragraph.com/@cryptoshine/) **Published on:** 2022-06-09 **URL:** https://paragraph.com/@cryptoshine/git-ssh-key ## Content 生成两个ssh密钥ssh-keygen -t rsa -C 'xxxxx@xxx.com' -f ~/.ssh/id_rsa_key1 ssh-keygen -t rsa -C 'xxxxx@xxx.com' -f ~/.ssh/id_rsa_key2 在 ~/.ssh 目录下config文件添加Host github1 HostName github.com User key1 IdentityFile ~/.ssh/id_rsa_key1 Host github2 HostName github.com User key2 IdentityFile ~/.ssh/id_rsa_key2 ssh 测试ssh -T git@github.com **成功返回:**Hi key! You've successfully authenticated, but GitHub does not provide shell access.在github SSH keys或Deploy keys 添加.pub 公钥SSH and GPG keys在项目目录下设置邮箱和用户名git config user.name "key1" git config user.email "xxxxx@xxx.com" ssh-add ~/.ssh/id_rsa_key1 完结 ## Publication Information - [cryptoshine.eth](https://paragraph.com/@cryptoshine/): Publication homepage - [All Posts](https://paragraph.com/@cryptoshine/): More posts from this publication - [RSS Feed](https://api.paragraph.com/blogs/rss/@cryptoshine): Subscribe to updates