AlmaLinuxRHEL Based

How To Enable SSH on AlmaLinux 10

Enable SSH on AlmaLinux 10

Secure Shell (SSH) stands as the cornerstone of remote Linux system administration, providing encrypted communication channels between clients and servers. For AlmaLinux 10 administrators, enabling SSH access represents a fundamental requirement for managing systems remotely, executing commands securely, and maintaining server infrastructure efficiently. This comprehensive guide walks you through every aspect of SSH configuration on AlmaLinux 10, from initial installation to advanced security hardening.

Whether you’re migrating from CentOS, exploring RHEL alternatives, or setting up a new AlmaLinux 10 environment, understanding SSH configuration ensures your systems remain accessible while maintaining robust security standards. The process involves multiple layers including service installation, firewall configuration, security optimization, and ongoing maintenance practices that safeguard your infrastructure against unauthorized access.

Understanding SSH and AlmaLinux 10

What is SSH?

SSH (Secure Shell) functions as a cryptographic network protocol enabling secure communication over unsecured networks. Unlike traditional remote access methods, SSH encrypts all data transmissions using advanced encryption algorithms, protecting sensitive information from interception. The protocol operates on a client-server architecture where SSH clients initiate connections to SSH servers (daemons) running on target systems.

Modern SSH implementations support multiple authentication methods including password-based authentication, public key cryptography, and certificate-based authentication. The protocol also facilitates secure file transfers, port forwarding, and tunneling capabilities, making it indispensable for system administration tasks. SSH version 2, the current standard, addresses security vulnerabilities found in earlier versions while providing enhanced functionality.

AlmaLinux 10 Overview

AlmaLinux 10 represents the latest iteration of this community-driven, enterprise-grade Linux distribution designed as a 1:1 binary compatible fork of Red Hat Enterprise Linux. Built on the foundation of stability and security, AlmaLinux 10 incorporates modern system management tools including systemd service management and firewalld for network security.

Fresh AlmaLinux 10 installations typically include SSH client tools by default but may require manual installation and configuration of the SSH server component. This design choice prioritizes security by ensuring administrators explicitly enable remote access services rather than exposing systems to potential security risks through default configurations.

Prerequisites and System Preparation

System Requirements

Before configuring SSH on AlmaLinux 10, ensure your system meets basic operational requirements. Your AlmaLinux 10 server should have sufficient resources for stable operation, including adequate RAM, storage space, and network connectivity. Administrative privileges through either root access or sudo permissions are essential for installing packages and modifying system configurations.

Network connectivity plays a crucial role in SSH functionality. Verify that your system can communicate with intended SSH clients and that no network-level restrictions prevent SSH traffic. Document your network configuration including IP addresses, subnet information, and any existing firewall rules that might affect SSH connections.

Initial System Updates

Maintaining current system packages ensures optimal security and compatibility before configuring SSH services. Execute comprehensive system updates using the DNF package manager, AlmaLinux 10’s default package management tool. Begin by refreshing package repositories to access the latest available software versions.

sudo dnf update -y
sudo dnf upgrade -y

These commands download and install all available package updates, including security patches and bug fixes. Following system updates, consider rebooting your AlmaLinux 10 system to ensure all kernel updates and system-level changes take effect properly.

Security Considerations

Understanding your system’s current security posture helps establish appropriate SSH configuration parameters. Review existing security policies, user account configurations, and network access controls before enabling SSH access. Document current firewall settings and network services to avoid conflicts during SSH configuration.

Consider implementing defense-in-depth security strategies that complement SSH access controls. This includes regular security auditing, log monitoring, and intrusion detection systems that provide comprehensive protection beyond SSH-specific security measures.

Installing OpenSSH on AlmaLinux 10

Checking Current SSH Installation

Before installing new SSH packages, verify existing SSH components on your AlmaLinux 10 system. The system may already include SSH client tools while requiring separate installation of the SSH server daemon. Use package management commands to identify currently installed SSH-related packages.

rpm -qa | grep openssh
dnf list installed | grep openssh

Distinguish between openssh-clients (for outgoing SSH connections) and openssh-server (for incoming connections). Most AlmaLinux 10 installations include openssh-clients by default, enabling administrators to connect to remote systems. However, accepting incoming SSH connections requires the openssh-server package.

Installing Required SSH Packages

Install the openssh-server package to enable incoming SSH connections on your AlmaLinux 10 system. The DNF package manager handles dependency resolution automatically, ensuring all required components are installed correctly.

sudo dnf install openssh-server -y

Verify successful installation by checking package status and confirming the SSH daemon binary exists in the expected system location. The installation process creates necessary system users, directories, and default configuration files required for SSH operation.

rpm -qi openssh-server
which sshd

Package Management Best Practices

When installing SSH packages, maintain awareness of package dependencies and repository sources. AlmaLinux 10 repositories provide tested, compatible SSH packages that integrate seamlessly with the operating system. Avoid installing SSH packages from untrusted sources that might introduce security vulnerabilities or compatibility issues.

Document all package installations for future reference and system auditing purposes. Maintain consistent package management practices across your infrastructure to ensure predictable behavior and simplified troubleshooting procedures.

Configuring and Starting SSH Service

Starting SSH Service

Once openssh-server installation completes, activate the SSH daemon using systemctl, AlmaLinux 10’s service management interface. The systemctl command provides comprehensive control over systemd services including starting, stopping, and monitoring service status.

sudo systemctl start sshd

Verify that the SSH service started successfully by checking its current status. The systemctl status command displays detailed information about service state, recent log entries, and any error conditions that might prevent proper operation.

sudo systemctl status sshd

Active SSH services display “active (running)” status along with process identification numbers and recent log entries. If the service fails to start, examine error messages carefully to identify configuration problems or missing dependencies.

Enabling SSH Service at Boot

Configure SSH to start automatically during system boot sequences to ensure consistent availability after system restarts. The systemctl enable command creates necessary symbolic links in systemd configuration directories, establishing SSH as a persistent system service.

sudo systemctl enable sshd

Distinguish between starting services immediately (systemctl start) and enabling automatic startup (systemctl enable). Both actions are typically required for production SSH configurations where remote access must remain available after system maintenance or unexpected reboots.

sudo systemctl is-enabled sshd
sudo systemctl is-active sshd

Service Management Commands

Master essential systemctl commands for comprehensive SSH service management throughout the system lifecycle. These commands provide complete control over SSH daemon operation, enabling administrators to respond quickly to service issues or configuration changes.

# Stop SSH service
sudo systemctl stop sshd

# Restart SSH service
sudo systemctl restart sshd

# Reload SSH configuration without disrupting existing connections
sudo systemctl reload sshd

# View detailed service status
sudo systemctl status sshd -l

# Follow SSH service logs in real-time
sudo journalctl -u sshd -f

Firewall Configuration for SSH

Understanding AlmaLinux 10 Firewall

AlmaLinux 10 employs firewalld as its default firewall management system, providing zone-based network security with dynamic rule management capabilities. Firewalld operates differently from traditional iptables configurations, offering more intuitive service-based rule management while maintaining powerful filtering capabilities.

Check your system’s current firewall status and active zones before modifying SSH access rules. Understanding existing firewall configurations prevents accidental security gaps or service disruptions during SSH enablement.

sudo firewall-cmd --state
sudo firewall-cmd --get-active-zones
sudo firewall-cmd --list-all

Allowing SSH Through Firewall

Enable SSH access through the firewalld by adding the SSH service to your active firewall zone. Firewalld includes predefined service definitions for common network services, including SSH, which simplifies rule management and reduces configuration errors.

# Add SSH service to the current zone temporarily
sudo firewall-cmd --add-service=ssh

# Add SSH service permanently
sudo firewall-cmd --add-service=ssh --permanent

# Reload firewall to apply permanent changes
sudo firewall-cmd --reload

Verify that SSH rules are active and properly configured by listing current firewall services. The firewall should display SSH as an allowed service in your active zone.

sudo firewall-cmd --list-services
sudo firewall-cmd --list-ports

Custom Port Configuration

Enhance security by configuring SSH to operate on non-standard ports, reducing automated attack attempts targeting the default SSH port (22). When using custom ports, update firewall rules accordingly to permit traffic on your chosen port number.

# Add custom SSH port to firewall
sudo firewall-cmd --add-port=2222/tcp --permanent
sudo firewall-cmd --reload

# Remove default SSH service if using custom port
sudo firewall-cmd --remove-service=ssh --permanent
sudo firewall-cmd --reload

SSH Configuration File Management

Understanding sshd_config

The SSH daemon configuration file (/etc/ssh/sshd_config) controls all aspects of SSH server behavior, security policies, and connection parameters. This critical file requires careful attention to detail, as misconfigurations can render systems inaccessible or create security vulnerabilities.

Create backup copies of configuration files before making modifications to ensure quick recovery from configuration errors. Establish version control practices for configuration management to track changes over time.

sudo cp /etc/ssh/sshd_config /etc/ssh/sshd_config.backup.$(date +%Y%m%d)
sudo cp /etc/ssh/sshd_config /etc/ssh/sshd_config.original

Basic Configuration Options

Configure fundamental SSH parameters to establish secure, functional remote access. Port configuration represents one of the most important security considerations, with many administrators choosing non-standard ports to reduce automated attack attempts.

Edit the SSH configuration file using your preferred text editor, making changes incrementally and testing configurations before implementing additional modifications.

sudo nano /etc/ssh/sshd_config

Key configuration directives include:

# Change default port for enhanced security
Port 2222

# Specify listening addresses (use 0.0.0.0 for all interfaces)
ListenAddress 0.0.0.0

# Use SSH protocol version 2 only
Protocol 2

# Set connection timeout values
ClientAliveInterval 300
ClientAliveCountMax 2

Advanced Security Settings

Implement sophisticated security controls through advanced SSH configuration options that restrict access, enhance authentication requirements, and limit potential attack vectors. These settings form the foundation of a robust SSH security posture.

# Disable root login for enhanced security
PermitRootLogin no

# Require public key authentication
PubkeyAuthentication yes
PasswordAuthentication no

# Limit user access to specific accounts
AllowUsers sshuser1 sshuser2
AllowGroups sshgroup

# Set maximum authentication attempts
MaxAuthTries 3

# Configure login grace time
LoginGraceTime 60

Security Best Practices

SSH Key Authentication

Implement SSH key-based authentication to eliminate password-related vulnerabilities while providing stronger security than traditional password authentication. SSH keys use asymmetric cryptography, making them significantly more resistant to brute force attacks and credential theft.

Generate SSH key pairs using modern, secure algorithms. RSA keys should use at least 2048-bit key lengths, though Ed25519 keys provide superior security with smaller key sizes and better performance characteristics.

# Generate Ed25519 key pair (recommended)
ssh-keygen -t ed25519 -C "user@almalinux10-server"

# Generate RSA key pair (alternative)
ssh-keygen -t rsa -b 4096 -C "user@almalinux10-server"

Deploy public keys to target systems using ssh-copy-id or manual file management. Ensure proper file permissions are maintained to prevent unauthorized access to key files.

# Copy public key to remote system
ssh-copy-id -i ~/.ssh/id_ed25519.pub user@almalinux10-server

# Manual public key deployment
cat ~/.ssh/id_ed25519.pub >> ~/.ssh/authorized_keys
chmod 600 ~/.ssh/authorized_keys
chmod 700 ~/.ssh

Access Control and User Management

Establish comprehensive user management practices that limit SSH access to authorized personnel while maintaining operational flexibility. Create dedicated SSH user accounts with appropriate permissions rather than sharing administrative credentials.

Configure sudo access for SSH users who require elevated privileges, implementing least-privilege principles that grant only necessary permissions for specific tasks. Document user access requirements and regularly audit account permissions.

# Create dedicated SSH user
sudo useradd -m -s /bin/bash sshuser

# Add user to sudo group
sudo usermod -aG wheel sshuser

# Set user password
sudo passwd sshuser

Advanced Security Measures

Deploy additional security layers including two-factor authentication, intrusion detection systems, and automated threat response mechanisms. These measures provide defense-in-depth protection against sophisticated attack vectors.

Consider implementing Fail2Ban to automatically block IP addresses exhibiting suspicious behavior patterns. Configure custom SSH banners to display legal notices and deter unauthorized access attempts.

# Install and configure Fail2Ban
sudo dnf install epel-release -y
sudo dnf install fail2ban -y
sudo systemctl enable fail2ban
sudo systemctl start fail2ban

Testing SSH Connections

Local Connection Testing

Verify SSH service functionality by establishing local connections before attempting remote access. Local testing identifies configuration errors and service issues without network complexity factors.

# Test SSH connection locally
ssh localhost

# Test with specific port
ssh -p 2222 localhost

# Test with specific user
ssh username@localhost

Remote Connection Testing

Establish remote SSH connections from external systems to validate network connectivity, firewall configurations, and authentication mechanisms. Test various connection scenarios including different user accounts and authentication methods.

# Basic remote connection
ssh username@almalinux10-server-ip

# Connection with custom port
ssh -p 2222 username@almalinux10-server-ip

# Connection with specific identity file
ssh -i ~/.ssh/id_ed25519 username@almalinux10-server-ip

Connection Validation

Verify that SSH connections function correctly across different scenarios including multiple simultaneous connections, various authentication methods, and different client systems. Document successful connection parameters for troubleshooting reference.

Monitor SSH logs during testing to identify potential issues and verify that security settings function as intended. Successful connections should generate appropriate log entries without error messages or security warnings.

Troubleshooting Common Issues

Service-Related Problems

Address SSH service startup failures by examining system logs and configuration file syntax. Common issues include port conflicts, configuration errors, and missing dependencies that prevent proper service initialization.

# Check SSH service status and logs
sudo systemctl status sshd -l
sudo journalctl -u sshd --no-pager

# Test configuration file syntax
sudo sshd -t

# Run SSH daemon in debug mode
sudo sshd -D -d

Connection and Authentication Issues

Resolve connection failures by systematically examining network connectivity, authentication configurations, and client-server compatibility. Connection timeouts often indicate firewall blocking or network routing problems.

# Test network connectivity
telnet almalinux10-server-ip 22
nc -zv almalinux10-server-ip 22

# Enable verbose SSH client output
ssh -v username@almalinux10-server-ip
ssh -vv username@almalinux10-server-ip

Firewall and Network Issues

Diagnose firewall-related connection problems by verifying port accessibility and rule configurations. Network issues may require coordination with network administrators to resolve routing or firewall policies.

# Check firewall rules
sudo firewall-cmd --list-all
sudo iptables -L -n

# Test port accessibility
sudo ss -tlnp | grep :22
sudo netstat -tlnp | grep :22

Monitoring and Maintenance

Log Monitoring

Establish comprehensive SSH log monitoring practices to detect security incidents, troubleshoot connection problems, and maintain system health. SSH logs provide valuable insights into access patterns and potential security threats.

# View SSH logs
sudo journalctl -u sshd
sudo tail -f /var/log/secure

# Filter failed login attempts
sudo grep "Failed password" /var/log/secure
sudo grep "Invalid user" /var/log/secure

Regular Maintenance Tasks

Implement routine maintenance procedures including security updates, configuration audits, and user access reviews. Regular maintenance ensures continued security and optimal performance of SSH services.

Schedule automatic security updates for SSH packages while maintaining configuration backup procedures. Establish change management processes for SSH configuration modifications to prevent unauthorized changes and maintain system stability.

Advanced Configuration Topics

SSH Tunneling and Port Forwarding

Leverage SSH’s advanced capabilities including local port forwarding, remote port forwarding, and dynamic SOCKS proxy functionality. These features enable secure access to internal network resources through encrypted SSH tunnels.

# Local port forwarding
ssh -L 8080:internal-server:80 username@almalinux10-server

# Remote port forwarding
ssh -R 8080:localhost:80 username@almalinux10-server

# Dynamic SOCKS proxy
ssh -D 1080 username@almalinux10-server

Integration with External Systems

Configure SSH integration with enterprise authentication systems including LDAP, Active Directory, and certificate authorities. These integrations provide centralized user management while maintaining SSH security benefits.

Consider implementing SSH certificate-based authentication for large-scale deployments requiring centralized key management and automated certificate rotation capabilities.

Congratulations! You have successfully installed SSH. Thanks for using this tutorial to enable SSH on your AlmaLinux OS 10 system. For additional help or useful information, we recommend you check the official SSH website.

VPS Manage Service Offer
If you don’t have time to do all of this stuff, or if this is not your area of expertise, we offer a service to do “VPS Manage Service Offer”, starting from $10 (Paypal payment). Please contact us to get the best deal!

r00t

r00t is an experienced Linux enthusiast and technical writer with a passion for open-source software. With years of hands-on experience in various Linux distributions, r00t has developed a deep understanding of the Linux ecosystem and its powerful tools. He holds certifications in SCE and has contributed to several open-source projects. r00t is dedicated to sharing her knowledge and expertise through well-researched and informative articles, helping others navigate the world of Linux with confidence.
Back to top button