Created
December 15, 2021 04:46
-
-
Save MahbbRah/a0021e69c6247a8c458b16ec5d8c25df to your computer and use it in GitHub Desktop.
Passwordless login with `ssh-copy-id` to a regular VPS or EC2 instances
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Passwordless Login | |
**NOTE:** For all the commands below if you use windows then use `git bash` terminal otherwise it will won't work | |
## Get Ready | |
First check if you have generated ssh keys in your local machine or not. hit this command on terminal to see if you've already | |
a ssh key `cat ~/.ssh/id_rsa.pub` if you see data then you're ready for next step otherwise generate ssh key first by hitting\ | |
this command `ssh-keygen` on terminal and it will ask you some prompt, you can just keep them blank and keep pressing enter, till | |
it's done! | |
## Passwordless login to EC2 VPS | |
Login always with the `pem` file is bit of annonying for regular access, So I've figure out ways to add your local development | |
machine authorized with EC2 instance as well by hooking up that command: | |
`cat ~/.ssh/id_rsa.pub | ssh -i aws.pem user@ip_address "cat - >> ~/.ssh/authorized_keys"` | |
Note: Also you might need to enable `PasswordAuthentication` to `yes` in `/etc/ssh/sshd_config` config file. | |
## Passwordless authentication with regular VPS that is accessible with password | |
This is a super easy-peasy job. To setup passwordless authentication there's a helper command in your terminal | |
called `ssh-copy-id`. So I'm expecting you've already `ssh` key generated. Now, Go ahead and hit command like this | |
`ssh-copy-id user@ip_address` then provide your login password and you'll see that 1 ssh key has been added or equivalent message | |
that means you're ready to go now just hit `ssh user@ip_address` it will won't ask you password again on your development machine! | |
~@Chill~/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment