1、修改远端sshd配置

sudo vi /etc/ssh/sshd_config
AllowAgentForwarding yes 
AllowTcpForwarding yes 
GatewayPorts yes 
X11Forwarding yes

2、example

ssh -R

# -R [bind_address:]port:host:hostport
ssh -p 22 -o TCPKeepAlive=yes -o ServerAliveInterval=5 -o ServerAliveCountMax=10 -o StrictHostKeyChecking=no root@remote-host -R 0.0.0.0:8888:192.168.9.1:80

ssh -L

# -L [bind_address:]port:host:hostport
ssh -p 22 -N -f -C -o TCPKeepAlive=yes -o ServerAliveInterval=10 -o StrictHostKeyChecking=no root@remote-host -L 0.0.0.0:8118:127.0.0.1:8118

ssh -D

# -D [bind_address:]port
ssh -qTfnN -D port root@remote-host
-q      Quiet mode.  Causes most warning and diagnostic messages to be suppressed.

-T      Disable pseudo-terminal allocation.

-f      Requests ssh to go to background just before command execution. 后台运行,并推荐加上 -n 参数
-n      Redirects stdin from /dev/null (actually, prevents reading from stdin).  This must be used when ssh is run in the background. 
-N      Do not execute a remote command.  This is useful for just forwarding ports.
-C      Requests compression of all data.

3、ssh慢

sudo vi /etc/ssh/sshd_config
UseDNS no
# GSSAPI options
GSSAPIAuthentication no

4、autossh