Securing SSH Connections from Windows
Create and secure .ssh user directory on Linux
mkdir ~/.ssh && chmod 700 ~/.ssh
Create Public/Private key pair from Windows Powershell
ssh-keygen -b 4096
You'll be prompted for a storage location which is best to leave at default.
You'll also be prompted to enter a passphrase to secure the key pair with, which is optional.
Copy Public key to Linux server from Windows Powershell
scp $env:USERPROFILE/.ssh/id_rsa.pub <username>@<serverIP>:~/.ssh/authorized_keys
You'll be prompted for your username and password to copy the file to the server.
Test logging into Linux server from Windows Powershell
ssh <username>@<serverIP>
You should not be prompted to enter a password anymore.
Secure SSH Service
sudo nano /etc/ssh/sshd_config
- Change
PermitRootLogin
tono
- Change
PasswordAuthentication
tono
Restart SSH Service
sudo systemctl restart sshd
Test logging into Linux server from Windows Powershell
Before logging off or closing the the currently connected session, test that you're still able to login to SSH.
ssh <username>@<serverIP>
No Comments