Logging in Using SSH

This section will show you how to connect to a Linux Server using Secure Shell (SSH)

ℹ️ Required Applications

To connect via SSH, you’ll need an SSH client. Here are some recommended options:

  1. For Windows:

    • PuTTY: A widely-used SSH client with a graphical interface.

    • Windows Command Prompt/PowerShell: Windows 10 and above include OpenSSH, so you can use cmd or PowerShell directly.

    • Windows Terminal: An enhanced terminal with support for multiple profiles and SSH.

  2. For macOS and Linux:

    • Terminal (Built-in): Both macOS and Linux have a built-in terminal with SSH capabilities.

  3. For Cross-Platform (Windows, macOS, Linux):

ℹ️ Prerequisites

Before starting, ensure you have:

  • The IP address or domain name of the server.

  • The username you’ll use to log in.

  • The password or SSH key for authentication.

📘 Step-by-Step Guide to Connect via SSH

1

Install and Open Your SSH Client

  • Windows: If you’re using PuTTY, download and install it. If you prefer the command line, you can use Command Prompt or PowerShell without additional installations.

  • macOS/Linux: Open Terminal (it’s pre-installed).

  • Visual Studio Code Users: Install the Remote - SSH extension from the Extensions Marketplace.

2

Get Your Server Details Ready

  • Server IP Address: Something like 192.168.1.10 or a domain name (e.g., example.com).

  • Username: Usually root or a specific user account on the server.

  • Password or SSH Key: For secure access.

3

Connect Using SSH

Option A: Using Terminal/Command Line

  1. Open the terminal on your device.

  2. Enter the following command, replacing [username] and [server_ip]:

    ssh [username]@[server_ip]

    Example:

  3. Enter the Password (if prompted):

    • If you’re using password-based authentication, you’ll be prompted to enter your password.

  4. Using SSH Keys (Optional):

    • If you’ve set up SSH keys, ensure your public key (~/.ssh/id_rsa.pub) is added to the server’s ~/.ssh/authorized_keys file.

    • The terminal will automatically use your SSH key if configured.

Option B: Using PuTTY (Windows Only)

  1. Open PuTTY.

  2. In the Host Name (or IP address) field, enter the server’s IP or domain.

  3. Set the Port to 22 (the default SSH port).

  4. Click Open.

  5. Login Prompt: When the terminal opens, enter your username, press Enter, then enter your password or use SSH keys as configured.

Option C: Using Visual Studio Code

  1. Open Visual Studio Code.

  2. Go to the Remote Explorer side panel, then click Connect to Host.

  3. Enter your SSH command (e.g., ssh [username]@[server_ip]).

  4. Enter your password or allow the SSH key if configured.

  5. You’ll now have remote access directly from VS Code.

4

Verify Connection

You should now be logged into the server. You’ll see a command prompt indicating your connection, usually with the server’s hostname and the username you’re logged in as.


🔧 Troubleshooting Tips

  • Permission Denied: Ensure you have the correct username, IP, and password. Check that your SSH key is correctly added if using key authentication.

  • Connection Timeout: Verify the server is online, and the firewall isn’t blocking port 22.

  • Add to Known Hosts: On first connection, you may be prompted to accept the server’s fingerprint. Type yes to continue.

With these steps, you’ll be connected to your server using SSH!

Last updated