Skip to content

Instantly share code, notes, and snippets.

@swagfin
Last active March 24, 2025 18:21
Show Gist options
  • Save swagfin/a9c9e73b76cb9588b2b56d5c28e80ca7 to your computer and use it in GitHub Desktop.
Save swagfin/a9c9e73b76cb9588b2b56d5c28e80ca7 to your computer and use it in GitHub Desktop.
How to install SSH Server and Allow root remove Login on Linux server

Allow Root User Access via SSH

1. Reset Ubuntu Root Password

Ensure you set a strong password:

sudo passwd root

2. Install OpenSSH Server and Client

Update the system and install both SSH components:

sudo apt update && sudo apt upgrade -y
sudo apt install openssh-server openssh-client -y

3. Enable Remote Root Login via SSH

Edit the SSH configuration file:

sudo nano /etc/ssh/sshd_config

Find and modify this line:

PermitRootLogin yes

Save and exit

4. Restart SSH Service

Apply the changes by restarting SSH:

sudo systemctl restart ssh

5. (Optional) Allow SSH Through the Firewall

If UFW (Uncomplicated Firewall) is enabled, allow SSH access:

sudo ufw allow ssh
sudo ufw reload

This setup ensures that both the SSH server (for receiving connections) and SSH client (for making connections) are installed properly.

@swagfin
Copy link
Author

swagfin commented May 23, 2023

Ensuring that your hostname is set correctly

you can check using hostname or hostnamectl

To change hostname, you can do so by:

hostname "local-vps-1"
hostnamectl set-hostname "local-vps-1"

@swagfin
Copy link
Author

swagfin commented May 23, 2023

To save you troubles with discovery issues, i prefer installing SAMBA server,

 sudo apt install samba -y

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment