Featured image of post SSH in a Nutshell

SSH in a Nutshell

SSH Explained


The History of SSH

SSH was created in 1995 by Tatu Ylönen, a Finnish researcher, in response to serious security vulnerabilities in Telnet and rlogin. These older protocols sent unencrypted passwords over the network, making them easy targets for man-in-the-middle attacks.

Why Was SSH Created?

  • Replace insecure protocols (Telnet, FTP, rlogin).
  • Encrypt all traffic to prevent eavesdropping.
  • Enable remote authentication via public/private keys.

Key Features of SSH

End-to-End Encryption → Protects passwords, data, and commands.
Public Key Authentication → Secure login without passwords.
Port Forwarding (Tunneling) → Encrypts arbitrary TCP connections.
File Transfer (SCP, SFTP) → Securely move files between systems.

Further Reading:


How SSH Works

SSH follows a client-server model:

  1. User initiates an SSH connectionssh user@server.com
  2. Server authenticates the user → Password or SSH key is verified.
  3. Encrypted session is established → Secure shell access begins.

How SSH Encryption Works

  • Uses public-key cryptography (RSA, Ed25519, ECDSA).
  • Ensures confidentiality (AES, ChaCha20) and integrity (HMAC).
  • Can authenticate with passwords, SSH keys, or Kerberos.

SSH vs. Modern Remote Access Alternatives

FeatureSSHRDP (Windows)TelnetVPN
Encryption✅ Yes✅ Yes❌ No✅ Yes
File Transfer✅ Yes (SCP, SFTP)❌ No❌ No✅ Yes
Graphical Support❌ No✅ Yes❌ No✅ Yes
Network Tunneling✅ Yes❌ No❌ No✅ Yes
Used ByLinux, Unix, WindowsWindowsLegacy systemsEnterprises

💡 Verdict: SSH is the best choice for command-line access, security, and automation.


SSH Command Examples

1. Connect to a Remote Server

1
ssh user@remote-server.com

2. Copy Files Using SCP (Secure Copy)

1
scp myfile.txt user@remote-server.com:/home/user/

3. Generate an SSH Key Pair

1
ssh-keygen -t ed25519 -C "my-email@example.com"

4. Copy SSH Key to a Server (Passwordless Login)

1
ssh-copy-id user@remote-server.com

5. Forward a Local Port to a Remote Server (SSH Tunneling)

1
ssh -L 8080:localhost:80 user@remote-server.com

6. Reverse SSH Tunnel (Remote Port Forwarding)

1
ssh -R 9000:localhost:22 user@remote-server.com

7. Run a Command on a Remote Server via SSH

1
ssh user@remote-server.com "ls -lah /var/www/"

8. Transfer Files Securely Using SFTP

1
2
3
sftp user@remote-server.com
sftp> get remote_file.txt
sftp> put local_file.txt

9. Monitor SSH Connections on a Server

1
who | grep pts

10. Prevent SSH Timeouts with Keep-Alive

1
echo "ServerAliveInterval 60" >> ~/.ssh/config

Key Takeaways

  • SSH is the most secure way to access remote machines.
  • Replaces outdated protocols like Telnet and FTP.
  • Supports authentication via passwords or SSH keys.
  • Can be used for tunneling, automation, and file transfers.

References

  1. SSH Wikipedia
  2. OpenSSH Project
  3. SSH vs. VPN
  4. Using SSH Keys