Skip to content

Instantly share code, notes, and snippets.

@roalcantara
Last active January 24, 2020 02:42
Show Gist options
  • Save roalcantara/75e14daf3d10060420590c3fa38684a2 to your computer and use it in GitHub Desktop.
Save roalcantara/75e14daf3d10060420590c3fa38684a2 to your computer and use it in GitHub Desktop.
Git push to remote with pem authentication
# generate public/private keys using ssh-keygen
ssh-keygen -t rsa
# change the permissions of the .pem file so only the root user can read it
chmod 400 amazon-generated-key.pem
# copy the machine to the remote repository
ssh-copy-id -i ~/.ssh/id_rsa.pub amazon-generated-key.pem ec2-user@amazon-instance-public-dns
# or
cat ~/.ssh/id_rsa.pub | ssh -i amazon-generated-key.pem ec2-user@amazon-instance-public-dns "cat >> .ssh/authorized_keys"
# try to connect without the pem
ssh ec2-user@amazon-instance-public-dns
# and push it to remote
git push remote local:master
@jbalatero
Copy link

tnx

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