Beginner 2 min read

๐Ÿ” SSH & SCP Basics (Beginner Friendly Guide)

๐Ÿ“Œ What Youโ€™ll Learn

  • What is SSH
  • How to connect to a server
  • What is SCP
  • How to transfer files securely
  • SSH key login (no password)

๐Ÿง  1. What is SSH?

SSH (Secure Shell) is used to: - Connect to a remote computer (server) - Run commands from your own terminal

๐Ÿ‘‰ You can control another machine from anywhere


๐Ÿงฉ Easy Analogy (Must Understand)

  • Your computer = ๐Ÿง‘โ€๐Ÿ’ป You
  • Server = ๐Ÿ  Another house
  • SSH = ๐Ÿ“ž Secure phone call

๐Ÿ‘‰ You sit at home and control another house remotely


โš™๏ธ 2. Install SSH (If Needed)

๐Ÿง Linux (Ubuntu/Debian)

sudo apt update
sudo apt install openssh-client

๐ŸชŸ Windows

  • Use PowerShell / CMD
  • Or install Git Bash

๐Ÿ”— 3. Connect to Server

ssh username@server_ip

โœ… Example:

ssh ubuntu@192.168.1.10

๐Ÿ“Œ First time: - Type yes - Enter password


๐Ÿ”‘ 4. SSH Key Login (No Password)

๐Ÿง  What is it?

Instead of typing password every time, you use a key system


๐Ÿงฉ Easy Analogy

  • Public Key = ๐Ÿ”“ Lock you give to server
  • Private Key = ๐Ÿ”’ Key you keep

๐Ÿ‘‰ If both match โ†’ access granted


๐Ÿช„ Step 1: Generate Key

ssh-keygen

๐Ÿ‘‰ Press Enter for all steps


๐Ÿ“ค Step 2: Copy Key to Server

ssh-copy-id username@server_ip

โœ… Example:

ssh-copy-id ubuntu@192.168.1.10

๐Ÿ”“ Step 3: Login Without Password

ssh username@server_ip

๐ŸŽ‰ Now no password needed


๐Ÿ“‚ 5. What is SCP?

SCP (Secure Copy) is used to: - Transfer files between your computer and server - Uses SSH (secure ๐Ÿ”’)


๐Ÿงฉ Easy Analogy

  • SSH = Talking to someone ๐Ÿ“ž
  • SCP = Sending files ๐Ÿ“ฆ

๐Ÿ“ค 6. Send File to Server

scp file.txt username@server_ip:/path

โœ… Example:

scp test.txt ubuntu@192.168.1.10:/home/ubuntu/

๐Ÿ“ฅ 7. Download File from Server

Basic command:

scp username@server_ip:/path/to/file .

โœ… Example:

scp ubuntu@192.168.1.10:/home/ubuntu/test.txt .

๐Ÿ”‘ Using Private Key (Important for VPS/Cloud)

If your server uses a private key (like AWS / OCI), use -i:

scp -i private.key username@server_ip:/path/to/file .

โœ… Example:

scp -i mykey.pem ubuntu@192.168.1.10:/home/ubuntu/test.txt .

๐Ÿงฉ Easy Analogy

  • Normal login = Password ๐Ÿ”‘
  • Key login = Special access card ๐ŸŽซ

๐Ÿ‘‰ Some servers only allow key-based entry, no password


๐Ÿ“ 8. Transfer Folder

scp -r folder_name username@server_ip:/path

โšก 9. Useful Tips

Custom port:

scp -P 2222 file.txt user@ip:/path

Use key:

ssh -i key.pem user@ip

๐Ÿšจ 10. Common Errors

โŒ Permission denied
๐Ÿ‘‰ Check username or key

โŒ Connection refused
๐Ÿ‘‰ Server not running or wrong IP


๐ŸŽฏ Conclusion

  • SSH = Remote control ๐Ÿ”Œ
  • SCP = Secure file transfer ๐Ÿ“ฆ
  • Use SSH keys for better security ๐Ÿ”