Setting up SSH on a machine with Linux Mint

It’s a short manual how to set up SSH connection on a Linux Mint machine from remotes. It can be also applied to another Linux builds like Debian, CentOS, Ubuntu.

1.Install OpenSSH Server

Start the machine you want to access. Be assured that it has Internet access to download packages. Open the terminal and install the OpenSSH server package:

sudo apt update
sudo apt install openssh-server -y

2.Enable and Start the SSH Service

Verify daemon is active. Ensure the SSH service is enabled to launch automatically on boot and start it now:

sudo systemctl enable ssh --now
sudo systemctl status ssh

3.Configure Local Firewall

By default SSH works on port 22. Allow SSH traffic through the Uncomplicated Firewall (UFW) or iptables:

sudo ufw allow ssh
# or explicitly: sudo ufw allow 22/tcp
sudo ufw reload

4.Identify the Host IP Address

Find your machine’s local IP address on the network with a command:

ip addr show | grep inet

5.Connect from a Remote Device

From your remote computer or terminal, initiate the connection using your username and IP address:

ssh username@192.168.x.x

To make an authorisation by certificate, please follow the next steps.

1. Run the following command on your local machine to generate a secure Ed25519 key pair.
Leave the passphrase empty by passing -N “” so it never prompts you for a password:

    ssh-keygen -t ed25519 -N "" -f ~/.ssh/id_ed25519

    Do it only on your personal PC!! Otherwise at least set the passphrase.

    2. Copy generated public key to the remote server:

    ssh-copy-id -i ~/.ssh/id_ed25519.pub username@remote_host

    If you use Windows, you don’t have ssh-copy-id in PowerShell. You should use this command:

    type $env:USERPROFILE.ssh\id_ed25519.pub | ssh username@remote_host "umask 077; mkdir -p ~/.ssh; tr -d '\r' >> ~/.ssh/authorized_keys"

    So, now you can connect to you server with SSH.

    Leave a Reply

    Your email address will not be published. Required fields are marked *

    Let us know you are human: