Remote SSH Cheat Sheet - Using Key

Connecting to Remote Server

Format:

ssh -i "/directory/your-key.pem" user@your-domain.com

Example:

ssh -i "~/.ssh/budi.pem" ubuntu@ec2-13-229-132-71.ap-southeast-1.compute.amazonaws.com


Copy File from Remote Server to Local

Format:

scp -i "/directory/your-key.pem" user@your-domain.com:/directory/server/example.txt /directory/local

Example:

scp -i "~/.ssh/budi.pem" ubuntu@ec2-13-229-132-71.ap-southeast-1.compute.amazonaws.com:/etc/nginx/nginx.conf ~/Downloads


Copy Folder from Remote Server to Local

Format:

scp -r -i "/directory/your-key.pem" user@your-domain.com:/directory/server/example /directory/local

Example:

scp -r -i "~/.ssh/budi.pem" ubuntu@ec2-13-229-132-71.ap-southeast-1.compute.amazonaws.com:/etc/nginx ~/Downloads


VSCode Configuration File

Format:

Host <your-domain.com> or <name>
    User <user-name>
    HostName <your-domain.com>
    IdentityFile <your-key.pem>

Example:

Host aws-ubuntu
    User ubuntu
    HostName ec2-13-229-132-71.ap-southeast-1.compute.amazonaws.com
    IdentityFile ~/.ssh/budi.pem

#ssh   #server