ssh remote port forwarding

علی ذوالفقار
1399/03/02 23:33:57 (544)
to forward remote port to local machine , use ssh port forwarding :
 ssh -R remoteport:local-address:localport user@server
 ssh -R 8080:
 autossh -M 0 -R remoteport:local-address:localport user@server
autossh -f -M 0 -o "ServerAliveInterval 10" -o "ServerAliveCountMax 3" -D localhost:1234 -N 
autossh -M 0 -o "ServerAliveInterval 10" -o "ServerAliveCountMax 3" -D localhost:1234 user@ip.address

Gateway Port Forward must be enabled in sshd_config file :
vi /etc/sshd_config
find and change GatewayPorst to yes :
GatewayPorts yes
now save config file and restart sshd service :
systemctl restart sshd
service sshd restart

forward local RDP to my server on port 13389 : 
    ssh -R 13389:

forward a PC(in LAN) RDP to my server on port 13389 :
    ssh -R 13389:

autossh : 
autossh -M 0 -o "ServerAliveInterval 1" -o "ServerAliveCountMax 5" -D local-ip:1080 root@remote
autossh -M 0 -D local-ip:1080 root@remote
ssh -D localportnumber accountname@servername
ssh -D 1080 root@remote-server

foreign server 
autossh -M 0 -R 222:localhost:22 root@iran-server

iran server
autossh -M 0 -D iran-server:21 -C root@ -p 222