Skip to content

Instantly share code, notes, and snippets.

@liviaerxin
Created March 8, 2023 06:46
Show Gist options
  • Save liviaerxin/0a9cf61ddb4181d2f8925b76c4015163 to your computer and use it in GitHub Desktop.
Save liviaerxin/0a9cf61ddb4181d2f8925b76c4015163 to your computer and use it in GitHub Desktop.
SSH Login Setup #ssh

SSH Login Setup

  1. Generate ssh key
# Generate ssh key with files(~/.ssh/id_rsa, ~/.ssh/id_rsa/pub) and username in default
ssh-keygen -t rsa

# Generate ssh key with specified files and username
ssh-keygen -t rsa -f ~/.ssh/[KEY_FILENAME] -C [USERNAME]
  1. Install ssh key to server
ssh-copy-id -i ~/.ssh/id_rsa.pub user@host
ssh-copy-id -i ~/.ssh/mykey.pub user@host

It equals to manually add the public key to ~/.ssh/authorized_keys

  1. Test ssh login with the new key
ssh -i ~/.ssh/mykey user@host
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment