Linux Setup SSH - Linux Tutorials - Learn Linux Configuration
Linux Setup SSH - Linux Tutorials - Learn Linux Configuration
org/linux-setup-ssh
Menu
The SSH protocol allows Linux administrators to log in to any number of remote
systems from their own command line terminal. SSH is a client-server service
providing secure, encrypted connections over a network connection. This allows us
terminal access to other Linux systems or really any device that accepts SSH
connections, such as routers and �rewalls, and other operating systems.
A user can also set up an SSH server on their own computer if they want to allow
incoming connections. This can be useful if you want to access your computer when
away from your desk, or you have other users on your system that need to use the
computer. In this tutorial, we will go over the step by step instructions to setup SSH
as both a client and server on all major Linux distros.
• How to install SSH Client and Server on all major Linux distros
1 of 11 4/7/23, 12:26 PM
Linux: Setup SSH - Linux Tutorials - Learn Linux Config... https://linuxconfig.org/linux-setup-ssh
So�ware OpenSSH
2 of 11 4/7/23, 12:26 PM
Linux: Setup SSH - Linux Tutorials - Learn Linux Config... https://linuxconfig.org/linux-setup-ssh
The �rst thing we need to do is install SSH. There are separate so�ware packages
available depending on if you want to install the client package, server package, or
both.
• The OpenSSH Client package will allow you to use SSH to log in or initiate
connections to remote systems.
• The OpenSSH Server package will allow you to setup the SSH service and
accept incoming connections. It is not necessary (or recommended) to install
this package if you only plan to use SSH as a client.
The SSH command is generally available by default on all Linux distributions, but if
your system does not have it, you can use the appropriate command below to install
the OpenSSH client package with your systemʼs package manager. The second
command in each example below will install the Server package (skip if you do not
need it).
To install OpenSSH Client and Server on Ubuntu, Debian, and Linux Mint:
To install OpenSSH Client and Server on Fedora, CentOS, AlmaLinux, and Red Hat:
3 of 11 4/7/23, 12:26 PM
Linux: Setup SSH - Linux Tutorials - Learn Linux Config... https://linuxconfig.org/linux-setup-ssh
$ ssh user@linuxconfig.org
Example 2 The default port for SSH to listen on is 22. If the remote system is
running the SSH service on some non default port, you can specify that port with the
-p option in your command. The following example shows how you would SSH into
a remote system thatʼs running the service on port 2210.
Example 3 Having SSH installed also gives us access to the scp command. The scp
command in Linux is used to copy �les and directories to or from a remote system.
It works very similarly to the cp command, except that it copies �les to or from other
systems that are either on your local network or somewhere over the internet. Letʼs
look at a simple example where we use the scp command to copy a local �le named
file.txt to a remote server with hostname linuxconfig.org .
4 of 11 4/7/23, 12:26 PM
Linux: Setup SSH - Linux Tutorials - Learn Linux Config... https://linuxconfig.org/linux-setup-ssh
Step 1 To begin accepting incoming SSH connections, we need to start the SSH
service with the systemctl command. To start or stop the SSH server:
Step 2 To enable (make SSH start automatically at system boot), or disable the SSH
server:
Step 3 Check whether the SSH server is running by using the systemctl status
command.
5 of 11 4/7/23, 12:26 PM
Linux: Setup SSH - Linux Tutorials - Learn Linux Config... https://linuxconfig.org/linux-setup-ssh
Step 4 In order to accept incoming connections, you will also need to allow the
service through your system �rewall. The commands for doing that may di�er
depending on your Linux distro. Use the appropriate ones below.
On Ubuntu and systems using ufw (uncomplicated �rewall):
6 of 11 4/7/23, 12:26 PM
Linux: Setup SSH - Linux Tutorials - Learn Linux Config... https://linuxconfig.org/linux-setup-ssh
Thatʼs all there is to it. As long as there is no physical router or �rewall blocking
connections to the SSH server, it should be ready to accept incoming connections.
With your SSH server ready to accept incoming connections, there are some
con�guration and security recommendations that you can apply. We have compiled
some of the most important ones below, and given you links to more in depth
tutorials for further reading:
• How to make the most of OpenSSH – Copying �les between machines with
scp , key based authentication, saved logins, mounting �le systems over SSH
• SSH remote login syntax and examples – Enabling root login, executing
commands over SSH, using tar over SSH, adding SSH aliases
• How to secure SSH best practices – Using SSH keys, changing default port,
allow speci�c users to log in
Closing Thoughts
In this tutorial, we saw how to setup SSH on a Linux system. This included using SSH
as a client package and ssh command, along with setting up SSH as a service that
listens for incoming connections. SSH is an essential protocol for most Linux
systems, as it allows you to open remote terminals to any number of systems, or to
manage your own system from over the internet. We can also do other handy things
like copy �les remotely, or create encrypted tunnels for other protocols.
7 of 11 4/7/23, 12:26 PM
Linux: Setup SSH - Linux Tutorials - Learn Linux Config... https://linuxconfig.org/linux-setup-ssh
System Administration
commands, networking, security, ssh
Setup FTP server on Linux
MX Linux vs Ubuntu
NEWSLETTER
Subscribe to Linux Career Newsletter to receive latest news, jobs, career advice and featured
8 of 11 4/7/23, 12:26 PM
Linux: Setup SSH - Linux Tutorials - Learn Linux Config... https://linuxconfig.org/linux-setup-ssh
con�guration tutorials.
SUBSCRIBE
WRITE FOR US
LinuxCon�g is looking for a technical writer(s) geared towards GNU/Linux and FLOSS
technologies. Your articles will feature various GNU/Linux con�guration tutorials and FLOSS
technologies used in combination with GNU/Linux operating system.
When writing your articles you will be expected to be able to keep up with a technological
advancement regarding the above mentioned technical area of expertise. You will work
independently and be able to produce at minimum 2 technical articles a month.
APPLY NOW
TAGS
ABOUT US
FEATURED TUTORIALS
9 of 11 4/7/23, 12:26 PM
Linux: Setup SSH - Linux Tutorials - Learn Linux Config... https://linuxconfig.org/linux-setup-ssh
How to install the NVIDIA drivers on Ubuntu 20.04 Focal Fossa Linux
How to install Tweak Tool on Ubuntu 20.04 LTS Focal Fossa Linux
How to Install Adobe Acrobat Reader on Ubuntu 20.04 Focal Fossa Linux
How to install the NVIDIA drivers on Ubuntu 18.04 Bionic Beaver Linux
Nvidia RTX 3080 Ethereum Hashrate and Mining Overclock settings on HiveOS Linux
LATEST TUTORIALS
Introduction to Vagrant
10 of 11 4/7/23, 12:26 PM
Linux: Setup SSH - Linux Tutorials - Learn Linux Config... https://linuxconfig.org/linux-setup-ssh
11 of 11 4/7/23, 12:26 PM