Skip to content

Instantly share code, notes, and snippets.

@ahgraber
Last active March 14, 2021 19:04
Show Gist options
  • Save ahgraber/e36c92e360e2f292e3cc47a3d48703b3 to your computer and use it in GitHub Desktop.
Save ahgraber/e36c92e360e2f292e3cc47a3d48703b3 to your computer and use it in GitHub Desktop.
SSH keys

Ref: https://docs.github.com/en/github-ae@latest/github/authenticating-to-github/generating-a-new-ssh-key-and-adding-it-to-the-ssh-agent

# generate key
ssh-keygen -t rsa -b 4096 -C "<your_email@example.com>"

# ensure ssh agent is running
eval "$(ssh-agent -s)"

# add key to agent
ssh-add -K ~/.ssh/id_rsa  # macOS
ssh-add ~/.ssh/id_rsa  # linux

# print public key to terminal for copying
cat ~/.ssh/id_rsa.pub

# share key to server
ssh-copy-id -i ~/.ssh/id_rsa.pub <USER>@<IPADDR>
# or with windows powershell
cat ~\.ssh\id_rsa.pub | ssh <USER>@<IPADDR> "cat >> .ssh/authorized_keys"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment