29 Mayıs 2023 Pazartesi

ssh Reverse Port Forwarding - Firewall Arkasındaki Sunucuya Erişmek İçindir

Giriş
Not : Açıklaması şöyle
For Remote Port forwarding the ssh server config /etc/ssh/sshd_config should have a property GatewayPorts yes
Açıklaması şöyle
Keep in mind that the ssh -R command requires SSH access to the remote server and proper authentication credentials. Additionally, the SSH server configuration on the remote host must allow port forwarding for this command to work.
ssh tunnel açmak için kullanılır. A <- Firewall <- B  olsun. B'den A'ya erişim var. Ancak B Firewall arkasında olduğu için A'nın B'ye erişimi yok.

Söz dizimi şöyle
ssh -R remote_port:local_address:local_port username@sshserver
Örnek
Şöyle yaparız
ssh -R 8888:localhost:8080 user@remote_host
Açıklaması şöyle
This command binds port 8888 on the remote server and forwards any incoming traffic to the web server running on localhost:8080 on your local machine. Now, you can access the web server on the local machine by connecting to http://remote_host:8888 from the remote server.

Örnek
A'dan B'ye erişmek için B'de şöyle yaparız.
$ ssh -f -N -R 1234:localhost:22 user@A_ip
A makinesinde şöyle yaparız.
$ ssh -p 1234 user@localhost
Örnek
Server <- Firewall <- Raspberry  olsun. Raspberry tarafında şöyle yaparız
rpi$ ssh -R 2222:localhost:22 username-on-server@server-ip-address
Sunucu makinede şöyle  yaparız
laptop$ ssh -p 2222 username-on-pi@server-ip-address

Hiç yorum yok:

Yorum Gönder