news for on-premise technologies
← Back to Blog

How to Set Up and Use SSH

SSH is the standard way to access remote servers securely. Whether you manage a single VPS or a rack of machines, setting up SSH correctly saves time and keeps your connections safe.

Install the OpenSSH server

On the remote machine, install and start the SSH daemon.

Arch Linux:

pacman -S openssh
systemctl enable --now sshd

Fedora:

dnf install openssh-server
systemctl enable --now sshd

Verify the service is running with systemctl status sshd. The default port is 22. Leave it as is unless you have specific security requirements.

Generate a key pair

From your local machine, generate an Ed25519 key pair. Ed25519 is faster and more secure than older RSA keys.

ssh-keygen -t ed25519 -C "your_email@example.com"

Accept the default location ~/.ssh/id_ed25519. Set a passphrase for the key. A passphrase encrypts the private key on disk so a stolen laptop does not expose your server access.

Copy the public key to the server

The easiest method is ssh-copy-id.

ssh-copy-id user@server_ip

This appends your public key to ~/.ssh/authorized_keys on the server and sets the correct permissions. If ssh-copy-id is not available, copy the key manually.

cat ~/.ssh/id_ed25519.pub | ssh user@server_ip "mkdir -p ~/.ssh && cat >> ~/.ssh/authorized_keys"
chmod 600 ~/.ssh/authorized_keys
chmod 700 ~/.ssh

Disable password authentication

Once key based login works, disable password authentication to prevent brute force attacks. Edit /etc/ssh/sshd_config on the server and set these values.

PasswordAuthentication no
PermitRootLogin no
PubkeyAuthentication yes

Restart the SSH daemon.

systemctl restart sshd

Test the connection in a second terminal before closing the first one. If something is wrong, you still have the original session open to fix it.

Streamline connections with config file

Create or edit ~/.ssh/config on your local machine to avoid typing IP addresses and flags repeatedly.

Host myserver
    HostName 192.168.1.100
    User myuser
    Port 22
    IdentityFile ~/.ssh/id_ed25519

Now connect with just ssh myserver instead of the full command.

Advanced tips

Use SSH agent forwarding when connecting through a jump box. Add ForwardAgent yes to your config or pass -A on the command line. This lets you authenticate from the jump box using your local keys without copying private keys to intermediate servers.

For frequently used servers, set up ControlMaster in your config to reuse a single TCP connection for multiple SSH sessions. This eliminates the connection overhead on subsequent logins.

Host *
    ControlMaster auto
    ControlPath ~/.ssh/control:%h:%p:%r
    ControlPersist 10m

SSH is a tool you reach for daily. Taking 15 minutes to configure it properly pays back in convenience and security for years.

References