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
👉 You sit at home and control another house remotely
sudo apt update
sudo apt install openssh-client
ssh username@server_ip
ssh ubuntu@192.168.1.10
📌 First time:
- Type yes
- Enter password
Instead of typing password every time, you use a key system
👉 If both match → access granted
ssh-keygen
👉 Press Enter for all steps
ssh-copy-id username@server_ip
ssh-copy-id ubuntu@192.168.1.10
ssh username@server_ip
🎉 Now no password needed
SCP (Secure Copy) is used to: - Transfer files between your computer and server - Uses SSH (secure 🔒)
scp file.txt username@server_ip:/path
scp test.txt ubuntu@192.168.1.10:/home/ubuntu/
Basic command:
scp username@server_ip:/path/to/file .
scp ubuntu@192.168.1.10:/home/ubuntu/test.txt .
If your server uses a private key (like AWS / OCI), use -i:
scp -i private.key username@server_ip:/path/to/file .
scp -i mykey.pem ubuntu@192.168.1.10:/home/ubuntu/test.txt .
👉 Some servers only allow key-based entry, no password
scp -r folder_name username@server_ip:/path
Custom port:
scp -P 2222 file.txt user@ip:/path
Use key:
ssh -i key.pem user@ip
❌ Permission denied
👉 Check username or key
❌ Connection refused
👉 Server not running or wrong IP