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.
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:
ssh remote_hostIf your remote username differs from your local one, use:
ssh remote_username@remote_hostTo exit an SSH session, type:
exitHow Does SSH Work?
SSH works by connecting a client program to an sshd server. Use SSH server with:
sudo systemctl start sshHow To Configure SSH
To configure SSH, edit /etc/ssh/sshd_config:
sudo nano /etc/ssh/sshd_config- Port: Default is 22. Change only if needed.
- PermitRootLogin: Set to
nofor better security. - LoginGraceTime: Adjust login time.
- X11Forwarding: Enable for GUI access with
-X.
After changes, reload SSH:
sudo systemctl reload sshHow To Log Into SSH with Keys
Key-based authentication uses a private and public key pair. Generate keys with:
ssh-keygen -t rsaTransfer your public key to the server:
ssh-copy-id remote_hostClient-Side Options
Match SSH server configurations with flags like:
ssh -p port_number remote_hostRun single commands remotely:
ssh remote_host command_to_runEnable X11 forwarding:
ssh -X remote_hostDisabling Password Authentication to Use SSH
Enhance security by disabling password authentication. Edit /etc/ssh/sshd_config:
PasswordAuthentication noReload the SSH daemon:
sudo systemctl reload sshConclusion 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.
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.