Copying File from Remote Server to Local Machine

Here’s a snippet how to get your files from remote server to your local machine using scp.

Copy to defined path.

$ scp user@host:/remote/file/path/data /local/target/destination/path

Copy to current directory.

$ scp user@host:/remote/file/path/data .

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/ | ssh root@[] "cat >> ~/.ssh/authorized_keys"

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



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 ' (' can't be established.
ECDSA key fingerprint is SHA256:*****************************.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '' (ECDSA) to the list of known hosts.
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