Cloud Knowledge

Your Go-To Hub for Cloud Solutions & Insights

Advertisement

Understanding SSH: The Backbone of Secure Remote Access and File Transfers

SSH Secure Remote Access and File Transfers

SSH (Secure Shell) is a protocol used for secure communication between devices over unsecured networks. It provides encryption to ensure confidentiality, integrity, and authenticity. Here’s a detailed breakdown of its components and uses:

Components of SSH

  • Network Protocol: SSH ensures secure communication for remote system access and operations.
  • Utility Suite:
    • ssh-keygen: Creates authentication key pairs for password-less and secure SSH access.
    • SCP (Secure Copy Protocol): Facilitates secure file copying between hosts over a network.
    • SFTP (Secure File Transfer Protocol): A secure alternative to FTP and FTPS for transferring files, leveraging SSH encryption.
  • Port and Accessibility

    The default port for SSH servers is TCP 22, though custom ports can be configured for added security or specific application needs.

    Key Features of SSH
    1. Remote System Management: Allows users to log in to remote computers and execute commands securely.
    2. File Transfers: Enables secure copying and sharing of files between systems using tools like SCP and SFTP.
    3. Secure Tunnels: Provides a method for tunneling other application protocols securely over a network, enhancing their security.

    Basic SSH commands

    SSH Commands
    1. ssh
      Connect to a remote server.

    2. ssh user@host
      Connect to a specific device or IP as a specified user.

    3. ssh user@host -p [port]
      Connect to a remote host using a specific port.

    4. ssh -i [keyfile] user@host
      Connect to a remote host using an identity (private key) file.

    5. ssh user@host 'command'
      Execute a command on the remote server.

    6. ssh user@host bash < script.sh
      Execute a local script on the remote server during the session.

    7. ssh user@host 'command' > output.file
      Execute a command remotely and save the output locally.

    SSH Key Management
    1. ssh-keygen
      Generate SSH keys (follow prompts).

    2. ssh-keygen -F [ip/hostname]
      Find an IP/hostname in ~/.ssh/known_hosts.

    3. ssh-keygen -R [ip/hostname]
      Remove an IP/hostname from ~/.ssh/known_hosts.

    4. ssh-keygen -f [filename]
      Specify the output file name when generating keys.

    5. ssh-keygen -y -f private.key > public.pub
      Generate a public key from a private key.

    6. ssh-keygen -c -f ~/.ssh/id_rsa
      Change the comment on a private key file.

    7. ssh-keygen -p -f ~/.ssh/id_rsa
      Change the passphrase of a private key.

    8. ssh-keygen -t [keytype] -b [bits] -C "[comment]"
      Generate a key with specific type, size, and comment.

    SCP Commands (Secure Copy)
    1. scp [source] [destination]
      Copy files between local and remote servers.

    2. scp user@host:/file ./
      Copy a file from remote to local.

    3. scp ./file user@host:/path/
      Copy a file from local to remote.

    4. scp user1@host1:/file user2@host2:/path/
      Copy a file directly between two remote servers.

    5. scp -r
      Recursively copy entire directories.

    6. Options:

      • -C: Compress data during transfer.
      • -v: Verbose output.
      • -p: Preserve file timestamps.
      • -P [port]: Specify the port for remote host.
      • -B: Batch mode, disables password prompts.
    SFTP Commands (Secure File Transfer Protocol)
    1. sftp [user@host]
      Start an interactive SFTP session.

    2. Options:

      • -p: Preserve timestamps.
      • -P [port]: Use a specific port.
      • -r: Recursively copy directories (no symlink traversal).

    Leave a Reply

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