top of page

CyberSecurity 101: Complete SSH SETUP on Linux.

SSH (Secure Shell) is a protocol that allows you to connect securely to another computer over a network.Unlike Telnet or FTP, SSH encrypts all communication — including your login credentials — ensuring that no one can intercept or modify what you send.

In practical terms, SSH lets you control remote Linux systems, run commands, transfer files, or even tunnel connections — all securely.It’s the foundation of remote administration used by developers, sysadmins, and cybersecurity experts worldwide.

Why You Should Generate an SSH Key (and Keep It Private)

  • Better Security Than Passwords: SSH keys authenticate users without sending a password across the network.

  • Convenience and Automation: Log in or run scripts without entering your password each time.

  • Access Control: Easily revoke or replace a public key without changing any passwords.

  • Privacy by Design: Your private key (~/.ssh/id_rsa) must remain private — if others can read it, SSH will refuse to use it.

⚙️ How to Generate and Secure Your SSH Key

Step 1 — Generate an SSH Key

ssh-keygen -t rsa -b 4096 -f ~/.ssh/id_rsa -C "your_email@example.com"

or

ssh-keygen -t ed25519 -f ~/.ssh/id_ed25519 -C "your_email@example.com"

Follow the prompts and set a strong passphrase.

Step 2 — Secure File Permissions

chmod 700 ~/.ssh
chmod 600 ~/.ssh/id_rsa
chmod 644 ~/.ssh/id_rsa.pub
700 = only you can access .ssh directory600 = private key readable only by you644 = public key can be safely shared

Step 3 — Add Your Public Key to a Remote Server

Use the easiest method:

ssh-copy-id -i ~/.ssh/id_rsa.pub user@remote.example.com

Or manually:

cat ~/.ssh/id_rsa.pub | ssh user@remote.example.com \
  'umask 077; mkdir -p ~/.ssh; cat >> ~/.ssh/authorized_keys; chmod 700 ~/.ssh; chmod 600 ~/.ssh/authorized_keys'

Step 4 — Test the SSH Connection

ssh user@remote.example.com
# or
ssh -i ~/.ssh/id_rsa user@remote.example.com

If successful, you’ll log into your remote terminal:

Welcome to Ubuntu 22.04 LTS
user@remote:~$

💻 How to Connect and Test SSH on Linux

  1. Ensure SSH Server Is Running (Remote):

    sudo systemctl status ssh sudo systemctl start ssh

  2. Send Your Public Key:

    ssh-copy-id -i ~/.ssh/id_rsa.pub user@ip

  3. Connect:

    ssh user@ip

🧩 Optional: Simplify Your Setup with SSH Config

Edit your config file:

nano ~/.ssh/config

Add:

Host myserver
    HostName x.xx.xx.xxx
    User user
    IdentityFile ~/.ssh/id_rsa

Now connect easily with:

ssh myserver

🚨 Troubleshooting Common SSH Issues

Quick SSH Setup Checklist

  •  Generate SSH key → ssh-keygen -t rsa -b 4096

  •  Protect private key → chmod 600 ~/.ssh/id_rsa

  •  Copy public key to remote → ssh-copy-id -i ~/.ssh/id_rsa.pub user@host

  •  Test connection → ssh user@host

  •  Use SSH config for shortcuts

  •  Revoke keys by editing authorized_keys

Conclusion: Secure Connections Made Simple

SSH is more than a command — it’s the backbone of secure Linux communication.By generating your own key pair, setting permissions, and testing connections, you gain full control over remote access the safe way.Once configured, SSH becomes one of those tools you’ll use daily without even thinking about it — quietly doing the heavy lifting behind every secure session.

 
 
 

Comments


bottom of page