Tutorials  /  Linux Basics

How To Use SSH to Connect to a Remote Server

Ccentron Redaktion · January 2025 ·4 min read ·Linux Basics, Tutorial

Introduction to Use SSH

One essential tool to master as a system administrator is SSH.

SSH, or Secure Shell, is a protocol used to securely log onto remote systems. It is the most common way to access remote Linux servers.

In this guide, we will discuss how to use SSH to connect to a remote system.

VM

Matching infrastructure at centron

No hardware needed to follow along: ccloud³ VMs with full root access start at €3.12 per month, billed by the hour and ready in seconds. Rent a cloud server →

Core Syntax

To connect to a remote system using SSH, we’ll use the ssh command.

If you are using Windows, you’ll need to install OpenSSH or alternatives like WSL. On Mac or Linux, ssh is available by default.

The basic syntax for connecting is:

Code
ssh remote_host

If your remote username differs from your local one, use:

Code
ssh remote_username@remote_host

To exit an SSH session, type:

Code
exit

How Does SSH Work?

SSH works by connecting a client program to an sshd server. Use SSH server with:

Code
sudo systemctl start ssh

How To Configure SSH

To configure SSH, edit /etc/ssh/sshd_config:

Code
sudo nano /etc/ssh/sshd_config
  • Port: Default is 22. Change only if needed.
  • PermitRootLogin: Set to no for better security.
  • LoginGraceTime: Adjust login time.
  • X11Forwarding: Enable for GUI access with -X.

After changes, reload SSH:

Code
sudo systemctl reload ssh

How To Log Into SSH with Keys

Key-based authentication uses a private and public key pair. Generate keys with:

Code
ssh-keygen -t rsa

Transfer your public key to the server:

Code
ssh-copy-id remote_host

Client-Side Options

Match SSH server configurations with flags like:

Code
ssh -p port_number remote_host

Run single commands remotely:

Code
ssh remote_host command_to_run

Enable X11 forwarding:

Code
ssh -X remote_host

Disabling Password Authentication to Use SSH

Enhance security by disabling password authentication. Edit /etc/ssh/sshd_config:

Code
PasswordAuthentication no

Reload the SSH daemon:

Code
sudo systemctl reload ssh

Conclusion for Use SSH

Learning SSH will enhance your cloud computing capabilities. Its secure and lightweight design makes it invaluable for diverse scenarios. It simplifies remote server management, ensures encrypted connections, and supports advanced functionality like key-based authentication. With SSH, you can securely transfer files, execute commands, and manage multiple systems efficiently. Its flexibility makes it essential for developers, administrators, and anyone handling remote systems.

Jetzt 200 € Guthaben sichern

Testen Sie Ihr Setup auf ccloud³

Registrieren Sie sich in der ccloud³ und erhalten Sie 200 € Startguthaben für Ihr Projekt – z. B. für eine PostgreSQL-VM mit automatischen Backups.

centron Redaktion Technische Redaktion

Das Redaktionsteam von centron schreibt Anleitungen aus dem Betriebsalltag: getestet auf unserer eigenen Plattform, betrieben im Rechenzentrum in Hallstadt bei Bamberg.

Kategorie Linux Basics
Teilen
Noch offene Fragen?

Our team will help you with your specific setup - in German or English, by people who run the platform themselves.

War dieses Tutorial hilfreich?

Your answer is stored anonymously and helps us improve our tutorials.

Kommentare

No comments yet - be the first to ask a question about this tutorial.

Sign in to comment

Comments are open to centron customers. Sign in to your account to ask a question about this tutorial.

Weiterlesen

Das könnte Sie auch interessieren

Jetzt kostenlos anfangen

Melden Sie sich an und erhalten Sie in den ersten 60 Tagen ein Guthaben von 200 € bei centron.

Dieses Werbeangebot gilt nur für neue Konten. Angebot ausschließlich für Gewerbetreibende.

Jetzt loslegen Sales kontaktieren