-
-
Notifications
You must be signed in to change notification settings - Fork 2
Linux SSH Configuration
Mattscreative edited this page Dec 5, 2025
·
2 revisions
Complete beginner-friendly guide to SSH configuration on Linux, covering Arch Linux, CachyOS, and other distributions including server setup, client configuration, key-based authentication, and security hardening.
- Installing SSH
- SSH Server Configuration
- SSH Client Configuration
- Key-Based Authentication
- SSH Security
- Troubleshooting
Install SSH:
# Arch/CachyOS
sudo pacman -S openssh
# Debian/Ubuntu
sudo apt install openssh-server
# Fedora
sudo dnf install openssh-serverEnable service:
# Enable service
sudo systemctl enable --now sshd.service
# Check status
systemctl status sshdEdit config:
# Edit SSH config
sudo vim /etc/ssh/sshd_configSecurity settings:
# Disable root login
PermitRootLogin no
# Change port
Port 2222
# Disable password auth (use keys)
PasswordAuthentication no
# Allow specific users
AllowUsers username
# Disable empty passwords
PermitEmptyPasswords no
Restart SSH:
sudo systemctl restart sshdEdit client config:
# Edit config
vim ~/.ssh/configExample:
Host myserver
HostName server.example.com
User username
Port 2222
IdentityFile ~/.ssh/id_rsa
Connect to server:
# Basic connection
ssh user@server
# With config
ssh myserver
# With key
ssh -i ~/.ssh/key user@serverCreate SSH key:
# Generate key
ssh-keygen -t ed25519 -C "your_email@example.com"
# Or RSA
ssh-keygen -t rsa -b 4096Copy to server:
# Copy key
ssh-copy-id user@server
# Or manually
cat ~/.ssh/id_rsa.pub | ssh user@server "mkdir -p ~/.ssh && cat >> ~/.ssh/authorized_keys"Security settings:
# Edit config
sudo vim /etc/ssh/sshd_configAdd:
PermitRootLogin no
PasswordAuthentication no
PubkeyAuthentication yes
MaxAuthTries 3
Install fail2ban:
# Install fail2ban
sudo pacman -S fail2ban
# Enable
sudo systemctl enable fail2ban
sudo systemctl start fail2banCheck service:
# Check SSH status
systemctl status sshd
# Check firewall
sudo ufw statusCheck permissions:
# Check key permissions
chmod 600 ~/.ssh/id_rsa
chmod 644 ~/.ssh/id_rsa.pub
chmod 700 ~/.sshThis guide covered SSH configuration for Arch Linux, CachyOS, and other distributions, including server setup, client configuration, and security.
- Security Configuration - Security setup
- Remote Desktop - Remote access
- System Hardening - System hardening
- ArchWiki SSH: https://wiki.archlinux.org/title/OpenSSH
This guide covers Arch Linux, CachyOS, and other Linux distributions. For distribution-specific details, refer to your distribution's documentation.