Skip to content

Instantly share code, notes, and snippets.

@ultim8k
Created July 31, 2018 10:36
Show Gist options
  • Save ultim8k/417ca878e1d41198b3516da715ddc6c5 to your computer and use it in GitHub Desktop.
Save ultim8k/417ca878e1d41198b3516da715ddc6c5 to your computer and use it in GitHub Desktop.
Working with ssh keys

Working with ssh keys

Create an ssh key:

ssh-keygen -t rsa -b 4096 -C "[email protected]"

Start the ssh-agent in the background:

eval "$(ssh-agent -s)"

If you're using macOS Sierra or later, you will need to modify your ~/.ssh/config file to automatically load keys into the ssh-agent and store passphrases in your keychain.

Host *
    AddKeysToAgent yes
    UseKeychain yes
    IdentityFile ~/.ssh/id_rsa

Add your SSH private key to the ssh-agent and store your passphrase in the keychain.

ssh-add -K ~/.ssh/id_rsa

Then copy the public key to your clipboard:

pbcopy < ~/.ssh/id_rsa.pub

and add it to your github/bitbucket/gitlab/server.

Test ssh connection:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment