Tutorials  /  Linux Basics

How To Use SSH to Connect to a Remote Server

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

Contents

  1. Introduction to Use SSH
  2. Core Syntax
  3. How Does SSH Work?
  4. How To Configure SSH
  5. How To Log Into SSH with Keys
  6. Client-Side Options
  7. Disabling Password Authentication to Use SSH
  8. Conclusion for Use SSH

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 €4.04 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.

Claim €200 credit

Test your setup on ccloud³

Sign up for ccloud³ and receive €200 starting credit for your project.

centron Redaktion Technical editorial team

The centron editorial team writes guides from day-to-day operations: tested on our own platform, run in our data centre in Hallstadt near Bamberg.

Category Linux Basics
Share
Still have questions?

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

Was this tutorial helpful?

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

Comments

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.

Get started for free

Sign up and receive €200 credit at centron within your first 60 days.

This promotional offer applies to new accounts only. Available exclusively to businesses.