Server

Register SSH Key To DigitalOcean

I just added new ssh key from my laptop into my digitalocean settings, to ensure next login in my laptop, I don’t need to type my password again and again. But after adding my ssh key and trying to login to my VPS, the ssh still asked me for a password.

Here is how I fix this following the documentation. I assuming that you guys know how to generate new ssh key. So below is next step after generating new ssh key.

$ cat ~/.ssh/id_rsa.pub | ssh root@[your.ip.address.here] "cat >> ~/.ssh/authorized_keys"

After run single command above, I don’t need to type password once logging in to my VPS.

Reference: https://www.digitalocean.com/community/tutorials/how-to-use-ssh-keys-with-digitalocean-droplets

AWS: Fix WARNING: UNPROTECTED PRIVATE KEY FILE!

I just moved my project to another laptop including “.pem” file for remote ssh to AWS EC2.
Once I’m trying to login to remote ssh, accidentally the authentication prompted security warning like below.

The authenticity of host '5x.xxx.xx.xxx (5x.xxx.xx.xxx)' can't be established.
ECDSA key fingerprint is SHA256:*****************************.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '5x.xxx.xx.xxx' (ECDSA) to the list of known hosts.
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@         WARNING: UNPROTECTED PRIVATE KEY FILE!          @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
Permissions 0644 for '/Users/adiyatmubarak/.ssh/key.pem' are too open.
It is required that your private key files are NOT accessible by others.
This private key will be ignored.
Load key "/Users/adiyatmubarak/.ssh/key.pem": bad permissions

I guess because the file permission, and here is my current permission.

-rw-r--r--@  1 adiyatmubarak  staff  1675 Aug  5 13:19 key.pem

The problem solved after I only grant my user on my “.pem” file.

$ chmod 600 key.pem
$ ls -la
$ -rw-------@  1 adiyatmubarak  staff  1675 Aug  5 13:19 key.pem