~2 min read • Updated Jul 21, 2025
1. What Is SSH?
ssh enables encrypted remote shell access between Linux machines. You can remotely log in to servers and manage systems securely.
ssh user@hostname
Example:
ssh [email protected]2. Installing SSH
- SSH client: Usually preinstalled
- SSH server: Required on destination machine
sudo apt install openssh-server
sudo systemctl enable --now ssh3. Common SSH Options
- -p: Specify a custom port
ssh -p 2222 user@host
ssh -i ~/.ssh/id_rsa user@host
ssh -L 8080:localhost:80 user@host
4. What Is SCP?
scp copies files securely between hosts over SSH. It encrypts both credentials and file data during transfer.
5. Upload File from Local to Remote
scp file.txt [email protected]:/home/user/6. Download File from Remote to Local
scp [email protected]:/home/user/file.txt ./7. Copy Folders with SCP
scp -r myfolder/ user@host:/home/user/8. Important SCP Flags
| Option | Purpose | Example |
|---|---|---|
| -P | Custom SSH port | |
| -i | Private key authentication | |
| -r | Recursive folder copy | |
| -v | Verbose output for debugging | |
9. Security Best Practices
- Use SSH key pairs instead of passwords (
ssh-keygen) - Place public key in
~/.ssh/authorized_keyson remote host - Secure key permissions:
chmod 600 ~/.ssh/id_rsa - Configure firewall or
fail2banto prevent brute-force SSH attacks
10. Conclusion
ssh and scp are foundational tools for remote management and secure file transfers in Linux. Mastering them enables efficient and encrypted access between systems, strengthening both productivity and data security.
Written & researched by Dr. Shahin Siami