$ ssh user@server
ssh user@server
ssh user@server
Client -------- Key Exchange -------- Server -> shared secret key <-
Client -------- Key Exchange -------- Server -> shared secret key <-
Client -------- Key Exchange -------- Server -> shared secret key <-
ssh-keygen -t rsa -b 4096 -C "[email protected]"
ssh-keygen -t rsa -b 4096 -C "[email protected]"
ssh-keygen -t rsa -b 4096 -C "[email protected]"
ssh-copy-id user@server
ssh-copy-id user@server
ssh-copy-id user@server
cat ~/.ssh/id_rsa.pub
cat ~/.ssh/id_rsa.pub
cat ~/.ssh/id_rsa.pub
~/.ssh/authorized_keys
~/.ssh/authorized_keys
~/.ssh/authorized_keys
ls -la
Client -> (encrypted command) -> Server
Server -> (execute command)
Server -> (encrypted response) -> Client
Client -> (decrypt response)
Client -> (encrypted command) -> Server
Server -> (execute command)
Server -> (encrypted response) -> Client
Client -> (decrypt response)
Client -> (encrypted command) -> Server
Server -> (execute command)
Server -> (encrypted response) -> Client
Client -> (decrypt response)
ssh -L 3000:localhost:5432 user@remote-server
ssh -L 3000:localhost:5432 user@remote-server
ssh -L 3000:localhost:5432 user@remote-server
localhost:3000
localhost:3000
localhost:3000
# Disable password authentication (server-side)
PasswordAuthentication no
# Disable password authentication (server-side)
PasswordAuthentication no
# Disable password authentication (server-side)
PasswordAuthentication no
# Set correct permissions
chmod 700 ~/.ssh
chmod 600 ~/.ssh/authorized_keys
# Set correct permissions
chmod 700 ~/.ssh
chmod 600 ~/.ssh/authorized_keys
# Set correct permissions
chmod 700 ~/.ssh
chmod 600 ~/.ssh/authorized_keys
# Use SSH agent
eval "$(ssh-agent -s)"
ssh-add ~/.ssh/id_rsa
# Use SSH agent
eval "$(ssh-agent -s)"
ssh-add ~/.ssh/id_rsa
# Use SSH agent
eval "$(ssh-agent -s)"
ssh-add ~/.ssh/id_rsa - No encryption yet
- Just a raw connection - SSH protocol versions
- Supported encryption algorithms
- Key exchange methods - Uses asymmetric cryptography (public/private keys)
- Establishes a fast symmetric session key
- Protects against eavesdropping and MITM attacks