I have a server and a remote computer. Now I want to access the remote computer via SSH, but it is possible that it is behind NAT. This is one of the reasons why I want a reverse SSH connection.
The idea is to establish a connection from a remote computer to the server and use this connection to communicate via SSH from the server to the remote computer.
With OpenSSH, it's pretty simple. From a remote computer, I open a reverse SSH tunnel:
ssh- R 19999:localhost:22 user@192.168.0.10
Now I can use this from the server side:
ssh localhost -p 19999
I want to achieve the same behavior using the go and go SSH library application on a remote computer. The server will still use OpenSSH, so it should not be changed.
I know how to connect to a computer via SSH, but how to get the back part?
func main() { config := &ssh.ClientConfig{ User: "vagrant", Auth: []ssh.AuthMethod{ ssh.Password("vagrant"), }, } conn, err := ssh.Dial("tcp", "192.168.0.10:22", config) if err != nil { panic("Failed to dial: " + err.Error()) } }
source share