~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 ssh

3. Common SSH Options


  • -p: Specify a custom port
  • ssh -p 2222 user@host
  • -i: Use a private key for authentication
  • ssh -i ~/.ssh/id_rsa user@host
  • -L: Setup tunneling or port forwarding
  • 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


OptionPurposeExample
-PCustom SSH port
scp -P 2222 file.txt user@host:/path
-iPrivate key authentication
scp -i ~/.ssh/id_rsa file.txt user@host:/path
-rRecursive folder copy
scp -r dir/ user@host:/path
-vVerbose output for debugging
scp -v file.txt user@host:/path

9. Security Best Practices


  • Use SSH key pairs instead of passwords (ssh-keygen)
  • Place public key in ~/.ssh/authorized_keys on remote host
  • Secure key permissions: chmod 600 ~/.ssh/id_rsa
  • Configure firewall or fail2ban to 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