Setup ssh from bash

On the machine you want to initiate the SSH connection navigate to your home directory.

1
    cd ~ 

Check if a .ssh directory exists, if it does navigate inside. Otherwise run ssh and attempt to log into the machine with a username and password. Once successful, log out. There will now be a .ssh directory. Navigate inside.

Next, create a config file with vim config

Setup your host:

1
2
3
    Host raspberrypi
        HostName raspberrypi.lan
        User pi

Generate the ssh key:

1
    ssh-keygen -t rsa -b 4096 -C "comment here"

Then copy the key with:

1
    ssh-copy-id raspberrypi

To specific a specific key later, add IdentityFile ~/.ssh/keyfilehere.key to the config entry for the host


Last update: 2022-02-12 15:57:16