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