Support Online
Skip to main content

Guide to Establishing an SSH Connection: Secure Access to Remote Servers

💡 What Will You Learn in This Guide?

In this guide, you will learn how to securely connect to remote Linux servers using the SSH (Secure Shell) protocol.
We will apply basic SSH commands, SSH key creation, sshd_config settings and security optimizations step by step.

🧠 Technical Summary

Main Technical Topic: Establishing a secure connection to remote servers with SSH (Secure Shell) protocol
Problem it solves: Allows developers to run commands remotely via encrypted connections on unsecured networks.
Steps:

  1. Using the SSH command
  2. SSH client–server logic
  3. Server configuration (/etc/ssh/sshd_config)
  4. Creating and transferring keys
  5. Turning off password login

⚡ Quick Start: SSH Connection in 5 Steps

  1. Open Terminal

    • Linux/macOS: Start the terminal application.
    • Windows: Use PowerShell, Git Bash or WSL.
  2. Enter Connection Command

    ssh kullanici@sunucu_ip

This command sends a connection request to the remote server.

Give Security Confirmation Confirm the server identification fingerprint on the first connection.

Authenticate Enter your password or use your SSH key.

End Connection


exit

You log out and return to the local terminal.


📜 Basic SSH Syntax

Connecting with the Same Username


ssh sunucu_ip

If your local username is also valid on the remote system, you can connect without specifying a username.

Connecting with a Different Username


ssh uzak_kullanici@sunucu_ip

Example:


ssh trdev@203.0.113.55

This command connects to a virtual server on the GenixNode.


🧩 How Does SSH Work?

SSH establishes a secure connection between a client and the sshd service on the remote server.

Components: Client (ssh): The command you run in the terminal.

Server (sshd): The service that listens for the connection on the remote system.

To start the service in Ubuntu:


sudo systemctl start ssh

Enables the SSH service to be enabled.

💡 GenixNode Console: If you experience an SSH error, GenixNode's browser-based console is a secure alternative for emergency access.


🔑 Secure Login with SSH Keys

Key-based authentication rather than password is both more secure and faster.

Creating a Key Pair


ssh-keygen -t rsa -b 4096

Generates a private/public key pair with the RSA algorithm.

Default locations:


~/.ssh/id_rsa → Özel anahtar
~/.ssh/id_rsa.pub → Genel anahtar

Transferring the Public Key to the Server


ssh-copy-id kullanici@sunucu_ip

This command adds the public key to the server, allowing passwordless login.

Now:


ssh kullanici@sunucu_ip

You can log in directly with the command.


🔒 Securing SSH Server Configuration

Open the SSH configuration file:


sudo nano /etc/ssh/sshd_config
Önerilen Güvenlik Ayarları
Parametre Varsayılan Önerilen Açıklama
Port 22 2222 vb. Otomatik saldırılardan kaçınmak için farklı port seçin.
PermitRootLogin yes no Root girişi engellenir.
PasswordAuthentication yes no Parola girişini devre dışı bırakır.
X11Forwarding yes Gereksizse no GUI yönlendirmesini kapatır.

Save and reload the configuration:


sudo systemctl reload ssh

Enables the changes.


🚫 Disabling Login with Password (Security Step)

⚠️ Perform this step only if your SSH key is registered on the server.


sudo nano /etc/ssh/sshd_config

Find the line:


PasswordAuthentication no

Save and reload the service:


sudo systemctl reload ssh

Now only entry is possible with a key.


⚙️ Advanced SSH Commands

Connection via Different Port


ssh -p 2222 kullanici@sunucu_ip

Running a Single Command


ssh kullanici@sunucu_ip 'ls -l /var/www'

Runs the command on the server, returns the output to the local terminal.


🧰 Common SSH Errors and Solutions

ErrorWhySolution
Connection Refusedsshd service not workingCheck with sudo systemctl status ssh.
Permission Denied (Publickey)Incorrect permissions or missing keychmod 700 ~/.ssh && chmod 600 ~/.ssh/id_rsa
Host key verification failedIP changedRun the command ssh-keygen -R sunucu_ip.
SSH TimeoutNetwork or DNS problemExamine error details with ssh -vvv kullanıcı@sunucu.

🧩 SSH Config for Multiple Servers

Add to ~/.ssh/config to facilitate multiple connections:


Host genixnode-dev
HostName 192.168.1.10
User trdev
Port 2222
IdentityFile ~/.ssh/genixnode_dev_key

Link:


ssh genixnode-dev

Now you can connect directly with the shortcut.


🧱 SSH Security Checklist

✅ Disable password login (PasswordAuthentication no) ✅ Disable root logins (PermitRootLogin no) ✅ Change SSH port ✅ Only use key-based login ✅ Limit access with firewall ✅ Automate updates


❓ Frequently Asked Questions (FAQ)

  1. Why does SSH give a “Connection Refused” error?

SSHD service may be turned off on the server or the port is blocked by the firewall.

  1. How to solve the “Permission Denied (Publickey)” error?

It is caused by incorrect file permissions or missing key. Perform chmod 700 ~/.ssh and chmod 600 ~/.ssh/id_rsa.

  1. How do I work with multiple SSH keys?

You can define a different IdentityFile for each server in the ~/.ssh/config file.

  1. What does the “Host key verification failed” error mean?

The IP of the server may have changed. The ssh-keygen -R server_ip command clears the old record.

  1. Is SSH secure?

Yes, it provides encrypted connection. Disabling encrypted login and using key-based login increases security.


🎯 Result

SSH is the backbone of secure remote access for system administrators and developers. You can protect your servers by using SSH keys instead of passwords and following basic configuration steps.

☁️ Now create a Virtual Server in GenixNode and set up your own secure connection by following these steps!