linux sshd ubuntu - ghdrako/doc_snipets GitHub Wiki

Install

sudo apt install openssh-server
sudo ufw status
sudo ufw enable
sudo ufw allow ssh
sudo ufw reload

Generate server key

sudo sshd -d -p 2222
sudo mkdir /run/sshd

Start manual in debug mode

sudo sshd -d -p 2222

Reinstall

sudo apt-get -o Dpkg::Options::="--force-confmiss" install --reinstall openssh-client

sshd config file

sudo cat /etc/ssh/sshd_config

Change the Default SSH Port

sudo cp /etc/ssh/sshd_config /etc/ssh/sshd_config.bak
Port 33556 #  Port 22
sudo ufw delete allow ssh
sudo ufw allow 33556/tcp
sudo systemctl restart ssh
ssh -p 33556 [email protected]

Manage service

sudo systemctl status sshd
sudo systemctl start sshd
sudo systemctl enable --now ssh
journalctl -xeu ssh.service
sudo systemctl stop sshd
sudo systemctl reload sshd
sudo systemctl restart sshd