Linux
ssh 이용한 port forwarding (포트 포워딩)
도경다경
2022. 10. 13. 13:44
반응형
A, B 서버가 있다고 가정할 때
A서버의 특정 포트로의 통신을 B 서버로 포워딩 하고 싶을 때
다음과 같은 구문을 사용하여 백그라운드로 프로세스를 실행할 수 있다.
ssh -p [B port] -i [rsa_key_filename] -f -4 -C -N -L [A listen port]:[B 최종목적지 ip]:[B 최종목적지 port] [B user]@[B hostname]
ex)
ssh -p 8888 -i /home/osr/id_rsa -f -4 -C -N -L 50000:cafe.osr.com:443 osr@localpc
-p : port
-i : identity_file
-f : Requests ssh to go to background just before comand execution
-4 : Forces ssh to use IPv4 addresses only
-C : Requests compression of all data
-N : Do not execute a remote command.
-L : Specifies that the given port on the local (client) host is to be forwarede to the given host and port on the remote side.
port:host:hostport
어려워 보이는데
A서버에서는 50000번 port로 리슨 중이고 443 port 통해서 8888 포트인 것처럼 보내는 것
반응형