SSH (Secure Shell)
SSH is a secure protocol for remotely managing Linux systems. It allows you to execute commands on remote servers, transfer files, and manage systems securely.
Connecting to a Remote Machine
- Command:
ssh user@remote-host - Replace
userwith your username andremote-hostwith the server's IP or domain.
Troubleshooting Connection Issues:
- Authentication Failures:
- Ensure the correct username and password.
-
Check for missing or incorrect SSH keys.
-
Firewall or Port Issues:
- Verify that port 22 (default SSH) is open on the remote machine:
ss -tuln | grep 22
- Verify that port 22 (default SSH) is open on the remote machine:
Copying Files Securely
- Command:
scp file.txt user@remote-host:/path/to/destination
- Command:
rsync -av file.txt user@remote-host:/path/to/destination
Troubleshooting Example:
- If file transfers fail, ensure
scporrsyncis installed on both systems. - Verify permissions on target directories.
Key Management
See the SSH Keys instructions on how to properly setup your SSH Keys.
- Command:
ssh-keygen -t rsa
- Command:
ssh-copy-id user@remote-host
Troubleshooting Example:
- If key authentication fails:
- Verify the public key is present in
~/.ssh/authorized_keyson the remote server. - Check permissions for
~/.ssh(should be700) andauthorized_keys(should be600).
By mastering SSH, you'll be equipped to manage remote systems securely and efficiently.