SSH (Secure Shell)
SSH is used for secure remote login and other network services between two networked computers.
Client Commands
Connect to a Remote Server
ssh <user>@<hostname_or_ip>
Example: ssh <username>@192.168.1.5
Connect with a Specific Key
ssh -i <path_to_private_key> <user>@<host>
Server Configuration (/etc/ssh/sshd_config)
Common configuration tasks on the server side. After changing config, always restart the service:
Restart SSH (sudo systemctl restart sshd)
Important Settings
- PermitRootLogin:
no(Disables direct root login for security) - PasswordAuthentication:
no(Requires SSH keys, disables password login) - PubkeyAuthentication:
yes(Enables SSH key authentication) - UsePAM:
yes
Managing Authorized Keys
To allow a user to connect, add their public key to ~/.ssh/authorized_keys.
nano ~/.ssh/authorized_keys
# Paste the public key, save, and exit.
chmod 600 ~/.ssh/authorized_keys