Linux 命令
查询占用端口的程序
sudo netstat -nlp | grep :80
sudo lsof -n -i :80 | grep LISTEN
查询占用端口的程序
sudo netstat -nlp | grep :80
sudo lsof -n -i :80 | grep LISTEN
ssh -L [LOCAL_IP:]LOCAL_PORT:DESTINATION:DESTINATION_PORT [USER@]SSH_SERVER
ssh -L 5901:127.0.0.1:5901 -N -f user@remote.host
The -f
option tells the ssh
command to run in the background and -N
not to execute a remote command. We are using localhost
because the VNC and the SSH server are running on the same host.
ssh -R [REMOTE:]REMOTE_PORT:DESTINATION:DESTINATION_PORT [USER@]SSH_SERVER
GatewayPorts yes
允许从外部访问远程主机转发端口
ssh -R 8080:127.0.0.1:3000 -N -f user@remote.host
The command above will make the ssh server listen on port 8080, and tunnel all traffic from this port to your local machine on port 3000.
https://linuxize.com/post/how-to-setup-ssh-tunneling/