Show all entries

Sun 2023-08-27

Configuring SSH on a new machine

First install openssh-server on the new machine and create the .ssh directory:

$ sudo apt install openssh-server
$ mkdir -m 700 .ssh

On the old machine, edit the .ssh/config file and add an entry for the new machine, which I'll call "new" in this example. You'll need to get the IP address of the new machine on your network by looking at the Wifi settings.

Host new
hostname 192.168.1.234

Now on the old machine copy these two files over to the new machine:

$ cd .ssh
$ scp id_rsa.pub new:.ssh/
$ scp authorized_keys new:.ssh/

Each of those copy commands will ask you to enter the password, which is annoying but we will soon get to a place where ssh will use public key authentication and you won't need to enter passwords any more.

On the new machine, do this:

$ sudo su -
# vi /etc/ssh/sshd_config

Now inside that file set these options:

PermitRootLogin yes
PubkeyAuthentication yes
PasswordAuthentication no
UsePAM yes

Write out the file and then run:

# systemctl restart sshd

Now you'll be able to copy files from old to new without entering a password each time. You'll just enter the password of your private key once.