WindowsMacSoftwareSettingsSecurityAndroidProductivityLinuxPerformanceAppleDevice Manageme.. All

How to Set Up SSH on Fedora

Edited 1 week ago by ExtremeHow Editorial Team

FedoraSSHSetupSecure ShellNetworkingRemote AccessCommand LineTerminalConfigurationComputers

How to Set Up SSH on Fedora

This content is available in 7 different language

Setting up SSH (Secure Shell) on the Fedora operating system is a basic skill that enables users to securely connect to a remote server or other device. SSH provides a secure way to access devices over an unsecured network. This guide will walk you through the comprehensive steps to set up SSH on Fedora, ensuring that you can effectively establish secure communications in your network environment.

Understanding SSH

Before we proceed with the setup process, it is important to understand SSH. SSH stands for Secure Shell, and it is a network protocol that provides administrators with a secure way to access devices over an unsecured network. SSH is often used to remotely manage systems and applications, with the benefit of encrypted communications to protect data from unauthorized access.

SSH typically authenticates remote users using passwords or cryptographic keys, and provides encrypted communications to ensure data security. This makes it an essential tool for system administrators, developers, and users who need to securely manage remote machines.

Prerequisites

To setup SSH on Fedora you will need:

Step 1: Install OpenSSH Server

The first step to set up SSH on Fedora is to install the OpenSSH server. OpenSSH is a free and open-source version of the SSH connectivity tool, which is reliable for almost all distributions of Linux. Open a terminal window and run the following command:

sudo dnf install openssh-server

The `dnf` package manager will handle the installation. You will be asked to confirm the installation by typing `y` and pressing Enter. Once installed, you can verify the installation of the OpenSSH package by running the following:

rpm -q openssh-server

This command will return the installed package version if successful.

Step 2: Start the SSH service

After the OpenSSH server is installed, you must start and enable its service to accept incoming SSH connections. Start the SSH service with the following command:

sudo systemctl start sshd

To enable the SSH service on system boot, so that it starts automatically, use the command below:

sudo systemctl enable sshd

It is a good practice to check the status of the SSH service. This can be done using the command:

sudo systemctl status sshd

This command displays information about the status of the SSH service, allowing you to ensure that it is active and running properly.

Step 3: Configure the firewall

Fedora comes with a firewall enabled by default. You need to allow SSH connections through the firewall. Execute the following command to allow SSH traffic:

sudo firewall-cmd --permanent --zone=public --add-service=ssh

After making changes to the firewall configuration, reload the firewall to apply the changes:

sudo firewall-cmd --reload

This command ensures that firewall settings are updated and SSH connections are allowed.

Step 4: Configure SSH for security and preferences

The SSH server configuration is in the `/etc/ssh/sshd_config` file. It is good practice to review and possibly change this configuration for better security and performance depending on your needs.

You can open this configuration file using any text editor like `nano` or `vi`. Here, for example, we will use `vi`:

sudo vi /etc/ssh/sshd_config

In the configuration file, you can find many options to improve your server. Here are some common settings you may want to configure:

After making the changes, you must restart the SSH service for them to take effect:

sudo systemctl restart sshd

Step 5: Generate SSH keys (optional, but recommended)

SSH keys are a highly secure method of authentication, eliminating the need for passwords. Creating an SSH key pair involves creating a public and private key pair.

You can generate a key pair by using the following command:

ssh-keygen

You will be asked to enter a file in which to save the key, which is usually saved at the default location `~/.ssh/id_rsa`. Additionally, you have the option to set a passphrase to add another layer of security.

Once generated, the public key (usually located at `~/.ssh/id_rsa.pub`) must be added to the `~/.ssh/authorized_keys` file on the remote server you are connecting to. This allows the server to authenticate your connection using your key pair.

Step 6: Test your SSH setup

Once you have configured the SSH server, it is important to test the setup to make sure everything is working correctly. From your client machine, try SSHing into your Fedora server using:

ssh username@remote_host

Replace `username` with your actual username and `remote_host` with the IP address or hostname of your Fedora server. If you changed the SSH port, remember to include the `-p` option after the port number you specified in the configuration:

ssh -p 2200 username@remote_host

If everything is set up correctly, you will be able to connect securely to your Fedora server.

Conclusion

Setting up SSH on Fedora involves installing the OpenSSH server, starting and enabling SSH services, configuring the firewall, and making configuration adjustments to meet your security and functional requirements. In addition, using SSH keys significantly increases security and should be considered standard practice for SSH access.

With the steps in this guide, you should have a comprehensive understanding of how to run SSH on your Fedora system, giving you secure remote access and management capabilities.


© 2023 Fedora SSH Setup Guide

If you find anything wrong with the article content, you can


Comments