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:
- The 2nd computer has access to the 3rd computer
- The sshd config on the 2nd computer allows TCP forwarding (default is yes)