SSH

From SWKLS WIKI
Revision as of 14:30, 26 March 2020 by Unknown user (talk) (Created page with "SSH Key Setup Key Authentication with PuTTY Server-side Begin with generating proper folder permissions for .ssh Make sure you're under the proper user before entering code...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

SSH Key Setup Key Authentication with PuTTY Server-side Begin with generating proper folder permissions for .ssh

Make sure you're under the proper user before entering code

ssh-keygen Accept defaults for all prompts: [enter]

Now create an authorized keys file under the .ssh folder created, and set permissions

touch /home/<username>/.ssh/authorized_keys chmod 600 /home/<username>/.ssh/authorized_keys PuttyGen Inside of the puttygen program generate a key that will be used for connecting to the server

Under Actions heading click on Generate to generate a key pair When done, click on Save Private Key, and name it priv.ppk Manually copy and paste the public key starting from "ssh-rsa" down to the end of the key ending in "rsa-key-<numbers>" into a new file named public

Once you're done with this make sure to move a copy of the files into a new entry for KeePass

Server-side Copy the text of the public key you created, and insert it into the authorized_keys file:

vim /home/<username>/.ssh/authorized_keys Apply the key to a separate ssh session to make sure you've done everything correctly

Now to disallow root login and change other configuration for ssh:

sudo -i

  1. you are now under the root user

vim /etc/ssh/sshd_config

  1. Within the config change settings to match the following  !!Remove # sign if applicable!!
  2. PermitRootLogin no
  3. PasswordAuthentication no
  4. UsePAM no

Finally, Restart the sshd service to enable these changes:

sudo systemctl restart sshd