DropVPS Team
Writer: John hens
How to setup ssh on Centos 9

Table of Contents
Setting up SSH on CentOS 9 allows secure remote access to your server, providing encrypted communication for management, file transfer, and administration tasks.
Step 1: Update Your System
Before configuring SSH, update your CentOS 9 system to ensure all packages are up to date and compatible with the latest OpenSSH server.
sudo dnf update -y
Step 2: Install OpenSSH Server
Install the OpenSSH server package to enable SSH functionality on your CentOS 9 system. This provides secure remote management capabilities.
sudo dnf install -y openssh-server
Step 3: Start and Enable SSH Service
After installation, start the SSH service and enable it to run automatically at system boot for continuous availability.
sudo systemctl start sshd
sudo systemctl enable sshd
Step 4: Configure SSH Settings
You can enhance security by editing the SSH configuration file. For example, change the default port or disable root login to prevent unauthorized access.
sudo nano /etc/ssh/sshd_config
Example modifications:
Port 2222
PermitRootLogin no
PasswordAuthentication yes
Step 5: Restart SSH Service
After making changes to the SSH configuration, restart the SSH service to apply the new settings and ensure secure remote access works correctly.
sudo systemctl restart sshd
Step 6: Allow SSH Through Firewall
If the firewall is enabled, allow the SSH port to ensure remote connections can reach your CentOS 9 server.
sudo firewall-cmd --permanent --add-service=ssh
sudo firewall-cmd --reload
Step 7: Test SSH Connection
Finally, verify that SSH is working correctly by connecting from another device using the server’s IP address and the username.
ssh username@server_ip