File System Operations
- SSHFS: Mount remote file systems locally.
- Installation:
- Ubuntu/Debian:
sudo apt install sshfs - CentOS:
sudo yum install fuse-sshfs
Compression
- Compress Traffic:
- Use
ssh -C hostnameor addCompression yesto~/.ssh/configto enhance performance over slow connections. - Example with verbosity:
ssh -o "Compression yes" -v hostname.
- Use
X11 Forwarding
Forward Graphical Applications:
- Enable:
ssh -X user@serverorssh -o ForwardX11=yes user@server. - Trusted Forwarding (riskier):
ssh -Y user@server. - Disable:
ssh -x.
- Enable:
Configuration:
Client: Add to ~/.ssh/config
| Host * ForwardAgent yes ForwardX11 yes |
Server: Configure /etc/ssh/sshd_config:
| X11Forwarding yes |
| X11DisplayOffset 10 |
| X11UseLocalhost no |
Install xauth on the server for X11 authentication :
| sudo apt install xauth # Ubuntu/Debian |
| sudo yum install xauth # CentOS |
SSH Tunneling
Local Port Forwarding:
Route traffic from a local port to a remote machine.
Syntax:
ssh -L local_port:destination:remote_port user@ssh_server |
Example:
| ssh root@192.168.0.1 -L 2222:10.0.1.5:3333 |
Remote Port Forwarding:
Route traffic from a remote port back to a local machine.
Syntax:
| ssh -R [remote:]remote_port:destination:destination_port [user@]ssh_server |
Example:
| ssh -R 8080:192.168.3.8:3030 -N -f user@remote.host |
SOCKS Proxy:
Set up a dynamic proxy for traffic.
Syntax:
| ssh -D local_port_number user@remote_host |
Example with additional options:
| ssh -D 6677 -q -C -N -f me@192.168.5.5 |
ProxyJump (Bastion Host):
Connect to remote hosts via one or more intermediate hosts.
Syntax:
| ssh -J proxy_host1 remote_host2 |
Example (multiple hops):
| ssh -J user@proxy_host1:port1,user@proxy_host2:port2 user@remote_host3 |
Monitoring Traffic with SSH Tunnels
Tags:
5 advanced mac tricks advanced ssh awk command awk command in unix best linux commands chain commands linux Command Line Basics command line interface command-line commands linux basic commands linux command line linux command line ssh linux command line tutorial linux commands nano command nmap commands putty and basic linux commands repeat commands terminal ssh command ssh commands explained top linux commands top terminal commands
