What is SSH?
SSH (Secure Shell) is a protocol that lets you securely connect to your server's command line from anywhere. Think of it as a remote terminal — everything you can do physically on the server, you can do via SSH.
Why Use SSH?
- Speed — command-line operations are faster than GUI
- Power — access to tools not available in cPanel
- Automation — script repetitive tasks
- Troubleshooting — read logs, restart services, diagnose issues
Connecting via SSH
On macOS/Linux
Open Terminal and type:
ssh [email protected] -p 22On Windows
Use Windows Terminal (built-in) or PuTTY:
ssh [email protected] -p 22SSH Key Authentication (Recommended)
Password authentication works, but SSH keys are more secure:
# Generate a key pair
ssh-keygen -t ed25519 -C "[email protected]"
# Copy public key to server
ssh-copy-id [email protected]Now you can log in without a password.
Essential Commands
Navigation
pwd # Print current directory
ls -la # List files with details
cd /var/www # Change directory
cd .. # Go up one level
cd ~ # Go to home directoryFile Operations
cat file.txt # View file contents
nano file.txt # Edit file in terminal
cp file.txt backup.txt # Copy file
mv old.txt new.txt # Move/rename file
rm file.txt # Delete file (careful!)
mkdir new-folder # Create directoryPermissions
chmod 755 directory/ # Set directory permissions
chmod 644 file.txt # Set file permissions
chown user:group file # Change ownershipDisk & Memory
df -h # Disk space usage
du -sh folder/ # Folder size
free -m # Memory usage
top # Live process monitorWeb Server
# Apache
sudo systemctl restart apache2
sudo tail -f /var/log/apache2/error.log
# Nginx
sudo systemctl restart nginx
sudo tail -f /var/log/nginx/error.logPractical SSH Tasks
Compress & Download Files
# Create a tar.gz archive
tar -czf backup.tar.gz public_html/
# Extract an archive
tar -xzf backup.tar.gzDatabase Backup via Command Line
# MySQL dump
mysqldump -u username -p database_name > backup.sql
# Restore
mysql -u username -p database_name < backup.sqlSearch for Files
# Find files by name
find /home -name "*.php" -type f
# Search file contents
grep -r "error" /var/log/SSH Config File
Save connection details for quick access:
# ~/.ssh/config
Host myserver
HostName yourdomain.com
User username
Port 22
IdentityFile ~/.ssh/id_ed25519Now just type ssh myserver to connect.
Security Tips
- Disable password authentication after setting up SSH keys
- Change the default SSH port from 22 to something custom
- Use fail2ban to block brute-force attempts
- Keep your SSH client updated
- Never share private keys
Conclusion
SSH is the most powerful tool in a web administrator's toolkit. Start with basic navigation and file operations, then gradually explore more advanced features. Once you're comfortable with the command line, you'll wonder how you ever managed without it.