Securing SSH
Welcome
Quick how-to secure your ssh on linux server.
Instructions
-
First add user
sudo adduser <UserName>
-
Add user to sudoer group
sudo usermod -aG sudo <UserName>
-
Edit ssh configuration file
sudo nano /etc/ssh/sshd_config
Add these to end of the file:
ClientAliveInterval 360 # ssh Timeout ClientAliveCountMax 0 PermitEmptyPasswords no #Empty password text not permited AllowUsers <UserName> # Only alows entered users here Protocol 2 # User ssh protocol 2 (Latest) Port 222 # Change Port
-
Copy your ssh key to the server via (Mac/Linux)
ssh-copy-id <UserName>@10.0.0.1 -p 222 For Windows: Login via ssh, cd into .ssh folder nano authorized_keys Now you have created a new file where you can copy your personal computers pub key. Once you have completed above instructions, now you can disable password login sudo nano /etc/ssh/sshd_config add last line to the config file PasswordAuthentication no
-
Restart ssh services
sudo service sshd restart
Written on October 20, 2021