Below are some hints on setting up SSH for a new remote machine

Setup Passwordless Login

On local machine, do the following:

ssh-copy-id remote_username@server_ip_address

to copy public key to server.

Or we can manually copy to ~/.ssh/authorized_keys on the remote server

cat ~/.ssh/id_rsa.pub | ssh remote_username@server_ip_address "mkdir -p ~/.ssh && chmod 700 ~/.ssh && cat >> ~/.ssh/authorized_keys && chmod 600 ~/.ssh/authorized_keys"

If the key type is different, the filename needs to be adjusted accordingly. Use

ls ~/.ssh/id_*

to find the public key file

Config File

We can change the sshd_config file often in /etc/ssh:

Disable Password Configuration

PasswordAuthentication no

Disable Root Login

In sshd_config

PermitRootLogin no

Restart SSH Demon

Note that if we mode change to sshd_config file, we need to restart ssh daemon. On Ubuntu, we need to do

sudo systemctl restart ssh