Ref:
- https://gist.github.com/dentechy/de2be62b55cfd234681921d5a8b6be11
- https://gist.github.com/zentralwerkstatt/9e6c83e757cdfe430d6710585b2275c7
Steps:
-
Edit
/etc/ssh/sshd_config
as follows. Simply uncomment (remove #) the below lines and edit as needed.- Port 2222 # Or any port above 1000
- AddressFamily any
- ListenAddress 0.0.0.0
- ListenAddress ::
- PasswordAuthentication yes
-
Restart sshd as:
sudo service ssh --full-restart
-
If the above step shows error, such as
error: sshd: no hostkeys available -- exiting
, then generate the keys as follows:sudo ssh-keygen -A
. Then restart sshd again (Step 2). -
ssh localhost -p 2222
should work now. Enjoy.
Bonus Tip: Use tunnel if you need to make your ssh server (securely) accessible from the internet (across any NAT/Firewall).