Skip to content

SSH (Secure Shell)

SSH is a secure protocol for remotely managing Linux systems. It allows you to execute commands on remote servers, transfer files, and manage systems securely.

Connecting to a Remote Machine

  • Command:
    ssh user@remote-host
    
  • Replace user with your username and remote-host with the server's IP or domain.

Troubleshooting Connection Issues:

  1. Authentication Failures:
  2. Ensure the correct username and password.
  3. Check for missing or incorrect SSH keys.

  4. Firewall or Port Issues:

    • Verify that port 22 (default SSH) is open on the remote machine:
      ss -tuln | grep 22
      

Copying Files Securely

  • Command:
    scp file.txt user@remote-host:/path/to/destination
    
  • Command:
    rsync -av file.txt user@remote-host:/path/to/destination
    

Troubleshooting Example:

  • If file transfers fail, ensure scp or rsync is installed on both systems.
  • Verify permissions on target directories.

Key Management

See the SSH Keys instructions on how to properly setup your SSH Keys.

  • Command:
    ssh-keygen -t rsa
    
  • Command:
    ssh-copy-id user@remote-host
    

Troubleshooting Example:

  • If key authentication fails:
  • Verify the public key is present in ~/.ssh/authorized_keys on the remote server.
  • Check permissions for ~/.ssh (should be 700) and authorized_keys (should be 600).

By mastering SSH, you'll be equipped to manage remote systems securely and efficiently.