Skip to content

Key Based SSH from WIndows to Linux

T20A02 edited this page Sep 20, 2023 · 1 revision

Passwordless SSH:

  1. First on the client in power-shell run ssh-keygen from the user account you will be accessing with, and follow the prompts to create an SSH pair, and name them. You can choose note to add a password to the Keys, to make to not require one for SSH.

    image

  2. Now copy the public key (Default name id_rsa.pub) created by the client in the C:/Users/USER/.ssh/ directory, to the server with your method of choice. If this is an initial config, just ssh into the server using a password, use copy/paste, and echo to put the key in the home directory of the server user, in the directory with the name: ~/.ssh/authorized_keys.

    You can do this with echo "KEYCONTENTHERE" >> /home/USER/.ssh/authorized_keys

  3. Now enter the ssh config file on the server, located in /etc/ssh/sshd_config, and add the following to the file:

    RSAAuthentication yes
    PubkeyAuthentication yes
    

    to the end of the file. If you want to disable password based SSH set set PasswordAuthentication to no

    NOTE: this will disable password based ssh from other users, to the server system

    image

  4. Finally restart sshd using systemctl, and your Key based SSH is configured. Just ssh into the system using the normal command syntax, and you will be prompted if a key password was set, if not you will be logged in with no password request.