I have an Ubuntu Server and I want only a few PCs to be able to connect to my server via SSH (on port 22). Is there a way that I can create an certificate that I would install on the few PCs that are allowed on the server?
1 Answer
You can use ssh key-based authentication.
Generate private and public ssh key on one of PC using,
ssh-keygen
Configure your ubuntu server's /etc/ssh/sshd_config file
PubkeyAuthentication yes
PasswordAuthentication no
restart sshd service on ubuntu server
systemctl restart sshd.service
Add genetated public key into ubuntu servers /home/users-home/.ssh/authorized_keys
Place generated private key in /home/users-home/.ssh/ path on each PC.
-
the pcs i want to give the permissions to are windows machines. where to i have to put it there?– CruZerSep 19, 2019 at 11:38
-
you can use putty tool.. put the private key where you prefer. Sep 19, 2019 at 12:50
sudo ufw allow from 192.168.1.0/24 to any port 22
to allow a subnet, orsudo ufw allow from xxx.xxx.xxx.xxx to any port 22
to allow a specific IP. You can repeat this for all IPs to allow, and thensudo ufw enable
. Keep in mind you would need open any other services you provide in ufw as well:sudo ufw allow http
for example.