Login

Set hostname from /etc/hosts or the IP address. Use is optional if you’ve set up your configs.

$ ssh user@hostname

Enter the password if prompted.

Copy

$ scp foo.txt use@hostname:~/Downloads

Allow SSH access without password

Here we copy your public key to the other machine’s allowed public keys, so that can run SSH commands as usual but your machine with authenticate using keys and it won’t prompt you for a password. This approach is a lot harder to crack than a password.

Two approaches are covered below.

source

SSH Copy ID

We use the ssh-copy-id command here.

ssh-copy-id — use locally available keys to authorise logins on a remote machine

$ ssh-copy-id user@hostname

Optionally set an identify file.

$ ssh-copy-id -i ~/.ssh/id_rsa.pub user@hostname

Secure Copy

Alternative, using scp command.

$ scp $HOME/.ssh/id_rsa.pub foo@bar:~/.ssh/authorized_keys