Ubuntu OpenSSH Server config
Today I've Learned postGenerate ssh key
ssh-keygen -t rsa -b 4096 -C "[email protected]"
Install ssh server
sudo apt install openssh-client
sudo apt install openssh-server
Add public key
Add public key from laptop you want to login (cat .ssh/id_rsa.pub
) to
server you want to ssh with key.
To do that on server open: .ssh/authorized_keys
(if it doesn’t exist create new file)
vim ~/.ssh/authorized_keys
Paste in there the content of your laptop’s .ssh/id_rsa.pub
& save
note: there are 2 online tools dead drop & msg drop that will make your life easier if you want to transfer public key from one laptop to another
Disable password login
then edit /etc/ssh/sshd_config
sudo vim /etc/ssh/sshd_config
and make sure PasswordAuthentication
is to no
PasswordAuthentication no
in all past Ubuntu versions the value was commented with
#
and set to yes as default#PasswordAuthentication yes
. Make sure you don’t have#
in front ofPasswordAuthentication no
save and run
sudo systemctl restart sshd.service
https://ubuntu.com/server/docs/service-openssh
Now if you try to ssh to that server without that key you will see:
[email protected]: Permission denied (publickey).
Entire blog website and all the articles can be forked from this Github Repo