Skip to content

Instantly share code, notes, and snippets.

@tiagobbraga
Forked from mingderwang/log
Created January 19, 2024 20:34
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 tiagobbraga/0d0ec9fcdee1417737e6979845d544ff to your computer and use it in GitHub Desktop.
Save tiagobbraga/0d0ec9fcdee1417737e6979845d544ff to your computer and use it in GitHub Desktop.
add a public key for new host to ssh aws ec2
1. make a new public on local host (generate public key under ~/.ssh)
cd
ssh-keygen -t rsa -b 1024
2. copy the output of the following cat.
cat ~/.ssh/id_rsa.pub
3. ssh to your aws ec2 and paste it to ~/.ssh/authorized_keys2 (a new file)
4. chmod 640 ~/.ssh/authorized_keys2
5. go back to your local host and try to ssh it.
make sure the username is the same as the one you put public key on it's ~/.ssh directory.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment