Forums

Setting up reverse ssh from pythonanywhere

Sorry if this sounds familiar to https://www.pythonanywhere.com/forums/topic/12376/ I'm essentially using the same method as it is described in that post. on my remote machine :

ssh -R 49153:localhost:22 Username@ssh.pythonanywhere.com

On my python anywhere console:

ssh myremoteusrename@localhost -p 49153 -v  
OpenSSH_6.6.1, OpenSSL 1.0.1f 6 Jan 2014
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 19: Applying options for *
debug1: Connecting to localhost [::1] port 49153.
debug1: connect to address ::1 port 49153: Connection refused
debug1: Connecting to localhost [127.0.0.1] port 49153.
debug1: connect to address 127.0.0.1 port 49153: Connection refused
debug1: Connecting to localhost [127.0.0.1] port 49153.
debug1: connect to address 127.0.0.1 port 49153: Connection refused
ssh: connect to host localhost port 49153: Connection refused

Now from what I understand using "localhost" may be the problem, but could you suggest what could be the solution or workaround to get the reverse ssh connection to my device(it is behind NAT)?

Are you running the second ssh command in a console that you launched from the website on PythonAnywhere? If so, that's probably the problem. We have multiple console servers, and your console could be running on any one of them -- not necessarily the one where you started the reverse SSH server with the first command.

In order to be able to connect to your reverse SSH server via localhost, the best option would be to run the second command from a regular session that you start with ssh Username@ssh.pythonanywhere.com.

Hey that worked like a charm, thank you a lot for answer :)

Excellent, glad we could help :-)