Skip to main content

Command Palette

Search for a command to run...

Remote Access

Securely Connecting and Transferring Files

Published
โ€ข2 min read
Remote Access
S

Growing in DevOps, together! ๐Ÿค | Associate Software Engineer at Tech Mahindra | Enthusiastic about automation, cloud solutions, and efficient software delivery. | Let's connect, collaborate, and learn from each other!

Remote access allows you to securely connect to, transfer files, and synchronize data between computers over a network.


What is Secure Shell (SSH)?

SSH (Secure Shell) is a cryptographic network protocol used for securely accessing and managing remote computers over an untrusted network (like the Internet). It provides encrypted communication, protecting sensitive data like passwords and commands from being intercepted.

๐Ÿ”’ Key Features:
โœ” Secure remote login to servers
โœ” Encrypted data transmission
โœ” Remote command execution
โœ” File transfer via SCP and SFTP
โœ” Port forwarding and tunneling

How SSH Works?

SSH operates using the client-server model, where:

  • The SSH client (your computer) initiates a connection.

  • The SSH server (remote machine) listens for connections.

  • Both use public-key cryptography to establish an encrypted session.

๐Ÿ”‘ Authentication Methods:

  1. Password-based authentication (less secure)

  2. Public key authentication (more secure โ€“ uses SSH keys)1.SSH (Secure Shell)


Why it is called Secure Shell?

SSH (Secure Shell) is called Secure Shell because it provides a secure way to access and manage remote systems over an encrypted network connection. It replaces older, insecure protocols like Telnet, rlogin, and FTP, which transmit data (including passwords) in plaintext, making them vulnerable to interception and attacks.

Why is SSH Secure?

  1. Encryption: SSH encrypts all data transmitted between the client and server, preventing eavesdropping and man-in-the-middle attacks.

  2. Authentication: Supports password-based and key-based authentication, ensuring that only authorized users can access the system.

  3. Integrity Protection: Uses cryptographic hash functions to detect tampering with data during transmission.

  4. Forwarding and Tunneling: Supports secure tunneling for protocols like SCP and SFTP for secure file transfers.

    Note - The default port for SSH client connections is 22. We can change the default port and use one

    between 1024 and 32,767


Installation

  1. Install OpenSSH Client and Server

     sudo apt update
     sudo apt install openssh-client openssh-server -y
    
  2. Check SSH Service Status

     sudo systemctl status ssh
    


Commonly used ssh commands

  1. Connect to a Remote Server

     ssh user@remote_host
    
     ssh john@192.168.1.100
    

    This logs into 192.168.1.100 as user john.

  2. Specify a Custom Port (Default is 22)

     ssh -p 2222 user@remote_host
    
  3. Use an SSH Key Instead of a Password

     ssh -i /path/to/private_key user@remote_host
    
  4. Run a Command on the Remote Server

     ssh user@remote_host "command"
    
     ssh john@server.com "ls -l /home/john"
    
  5. Copy Files Securely with scp (SSH-Based File Transfer)

     scp file.txt user@remote_host:/remote/path/