Skip to content

Instantly share code, notes, and snippets.

@justin-lyon
Last active August 3, 2020 14:17
Show Gist options
  • Save justin-lyon/309ba1dd2664fb7b02d505ff8c75a261 to your computer and use it in GitHub Desktop.
Save justin-lyon/309ba1dd2664fb7b02d505ff8c75a261 to your computer and use it in GitHub Desktop.
ssh cheatsheet
# generate rsa key-pair without password (-N) with comment (-C) and name (-f)
ssh-keygen -t rsa -b 4096 -N "" -C "userName localName remoteName" -f keyName
# windows bash
# activate ssh-agent in windows bash
eval $(ssh-agent -s)
# list registered ssh keys - these keys are cached by the agent so you only need to enter pw once
ssh-add -l
# add private key to agent
ssh-add ~/.ssh/privateKeyName
# copy key to clipboard then paste to remote
clip < ~/.ssh/publicKeyName
# test a key pair connection
ssh -vT git@github.com
# How to end an unresponsive SSH session properly: Press Enter/Return, then type `~.`
# ~/.ssh/config
# very useful to manage multiple key-pairs
# configure ssh for git@github.com
```
Host myAlias
HostName github.com
User git
PreferredAuthentications publickey
IdentityFile ~/.ssh/privateKeyName
IdentitiesOnly yes
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment