When setting GitHub, the official instructions require that the current id_rsa be backed up and a new private key be generated for GitHub login. If this is done, the new private key cannot continue to log on to the previous machine. This method is a bit violent...
Fortunately, SSH allows us to log on to different domains using different private keys.
When adding a private key, you can specify different file names to generate different private key files.
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"
Add SSH configuration files and modify permissions
Touch ~ /. Ssh/configchmod 600 ~ /. Ssh/config
Modify the content of the config file
Host * .workdomain.com identityfile ~ /. Ssh/id_rsa.work user Lee host github.com identityfile ~ /. Ssh/id_rsa.github user git
In this way, SSH will read the corresponding private key file based on different domains.
Ssh-T [email protected]