سؤال

I am in my local computer, and i just want to test reverse ssh so that i access computer 2 and access computer 3 through computer 2 and make computer 3 respond to me in lets say i want to access postgresql on computer 3.

how to do that with ssh and using ports? 5432 is the port of sql

my approach is this:

ssh -L 3000:localhost:5432 <ipaddressof the 2nd computer>

so im inside 2nd computer now.

in the terminal again i type:

ssh -L 3000:localhost:5432 <ipaddress of the 3rd computer>

and im inside the 3rd computer now. And i dont know what to do anymore, how to access its sql?

i tried this code which doesn't work:

psql -U myusername -p 3000
هل كانت مفيدة؟

المحلول

Try the following:

ssh -L localhost:3000:<ip address 3rd computer>:5432 <ip address 2nd computer>

And then:

psql -U myusername -h localhost -p 3000

This works if:

  1. The 2nd computer has access to the 3rd computer
  2. The sshd config on the 2nd computer allows TCP forwarding (default is yes)
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top