Connecting to Linux Server via SSH

Detailed guide on how to connect to a Linux server via SSH

SSH (Secure Shell) is a protocol for secure remote access to a Linux server. This guide covers various methods of connecting to a server via SSH.

What is SSH?

SSH (Secure Shell) is a cryptographic network protocol for secure remote management of operating systems. It provides an encrypted connection between client and server, protecting transmitted data.

Preparation for Connection

Before connecting, make sure you have:

  • Server IP address — the public IP address of your VPS/VDS server
  • SSH port — usually port 22 (may be changed by administrator)
  • Username — usually root or another username created by the administrator
  • Password or SSH key — authentication credentials

Connecting via SSH on Windows

Method 1: Using PowerShell (Windows 10/11)

Modern versions of Windows have built-in SSH support in PowerShell and Command Prompt.

  1. Open PowerShell or Command Prompt (Win + R, type cmd or powershell).
  2. Execute the connection command:
    ssh username@ip-address
    
    For example:
    ssh root@192.168.1.100
    
  3. On first connection, the system will ask to confirm the key fingerprint. Type yes.
  4. Enter the password (password input is not displayed).

Method 2: Using PuTTY

PuTTY is a popular SSH client for Windows.

  1. Download and install PuTTY from the official website: https://www.putty.org/
  2. Launch PuTTY.
  3. In the "Host Name (or IP address)" field, enter your server's IP address.
  4. Specify the port (usually 22) in the "Port" field.
  5. Select connection type "SSH".
  6. Click "Open".
  7. In the terminal that appears, enter your username, then password.

Method 3: Using Windows Terminal

Windows Terminal is a modern terminal from Microsoft.

  1. Install Windows Terminal from Microsoft Store (if not already installed).
  2. Open Windows Terminal.
  3. Execute the command:
    ssh username@ip-address
    
  4. Enter password when prompted.

Connecting via SSH on Linux and macOS

On Linux and macOS, SSH client is usually installed by default.

  1. Open terminal.
  2. Execute the connection command:
    ssh username@ip-address
    
    For example:
    ssh root@192.168.1.100
    
  3. On first connection, confirm the key fingerprint by typing yes.
  4. Enter the user password.

Connecting with Port Specification

If the SSH server uses a non-standard port (not 22), specify the port in the command:

ssh -p 2222 username@ip-address

Connecting Using SSH Key

Using SSH keys is more secure than passwords.

Creating SSH Key (on Linux/macOS or Windows with OpenSSH)

  1. Create a key pair:
    ssh-keygen -t rsa -b 4096 -C "your_email@example.com"
    
  2. Press Enter to save in the default directory (~/.ssh/id_rsa).
  3. Enter a passphrase (can be left empty) or set a strong password.
  4. Copy the public key to the server:
    ssh-copy-id username@ip-address
    
    Or manually:
    cat ~/.ssh/id_rsa.pub | ssh username@ip-address "mkdir -p ~/.ssh && cat >> ~/.ssh/authorized_keys"
    

Connecting with Key

After setting up the key, connection happens automatically:

ssh username@ip-address

Troubleshooting Common Issues

"Connection refused" Error

  • Check that SSH service is running on the server: sudo systemctl status sshd
  • Make sure SSH port is open in firewall
  • Verify IP address and port are correct

"Permission denied" Error

  • Check username and password are correct
  • Make sure the user has access rights to the server
  • Check ~/.ssh/authorized_keys file settings on the server (for keys)

"Host key verification failed" Error

This error occurs when the server key has changed. To resolve:

  1. Remove the old entry from ~/.ssh/known_hosts file:
    ssh-keygen -R ip-address
    
  2. Connect again and confirm the new key.

Additional SSH Commands

Copying Files via SCP

# Copying file to server
scp file.txt username@ip-address:/path/to/destination

# Copying file from server
scp username@ip-address:/path/to/file.txt ./

# Copying directory
scp -r folder username@ip-address:/path/to/destination

Executing Command on Remote Server

ssh username@ip-address "command"

For example:

ssh root@192.168.1.100 "uptime"

SSH Security

Recommendations for secure SSH usage:

  1. Use SSH keys instead of passwords — this is a more secure authentication method
  2. Disable password login for root user (if possible)
  3. Change default SSH port (22) to a non-standard one
  4. Use strong passwords or keys with passphrase
  5. Limit access by IP addresses in firewall settings

Conclusion

Now you know how to connect to a Linux server via SSH using various methods. SSH is the standard and secure method for remote server management. Regularly update your system and monitor the security of your connections.

22.09.2024

© 2026 Hostinux.com Все права защищены.

Работайте безопасно. С заботой, Hostinux.

Оплачивайте с помощью банковских карт, ЮMoney, Perfect Money, Bitcoin, Ethereum, Litecoin, Monero и другой криптовалюты.

HOSTINUX LIMITED, Registration No. 16259388, 27 Old Gloucester Street, London, United Kingdom, WC1N 3AX

perfect moneybitcoinetheriumetheriummonerotethervisamastercardmir