Skip to content

Instantly share code, notes, and snippets.

@eladchen
Last active May 20, 2020 14:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save eladchen/f3e5f3303bb34a983c325c6f52f2d83e to your computer and use it in GitHub Desktop.
Save eladchen/f3e5f3303bb34a983c325c6f52f2d83e to your computer and use it in GitHub Desktop.
An example of using a specific ssh key for a given host

Generate a dedicated SSH key

SSH key creation

ssh-keygen -t rsa -b 4096 -f ~/.ssh/id-rsa-github -C "github.com"
chmod 600 ~/.ssh/id-rsa-github

Edit ~/.ssh/config:

Host github.com
  Hostname github.com
  User $__SSH_USER__$$
  IdentityFile ~/.ssh/id-rsa-github

Test SSH key

ssh -vT git@github.com

Reset passphrase

ssh-keygen -f ~/.ssh/id-rsa-github -p
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment