I'm working on setting up an unattended Ubuntu PC with Ubuntu Server 12.04 and since this PC will be placed in a remote location with no keyboard or screen (unattended), I need to have a permanent SSH connection from this machine to a middle-server (between itself and me) - reason being, this PC will be behind a NAT firewall.
I followed dot-to-dot instructions at
but when I connect, I just get an error
So I went back googling for a solution and found
ssh: connect to host 220.127.116.11 port 19999: Connection refused
Surprisingly, Alexonlinux's solution worked out-of-the-box.
Seeing this, I tried the previous method, this time using Port 6333, but no luck. Then I tried Alexonlinux's method using Port 19999 and again it works fine.
The reason I can't stick to Alexonlinux's solution is, that it requires some commands to be entered on the PC behind the NAT, and that's not possible in my case.
I really wonder what could be stopping the connection when using Fabelier's method. Maybe the script is not loading? I did try manually running the script but still no luck.
I have also set on the PC behind the NAT.
For the record, here's the script I've used from Fabalier's method
(obviously I've changed the <middle-usename>@<middle-hostname> to the necessary) I had to change the first line as brackets were not acceptable.
a=`ps -ef | grep 19999 | grep -v grep`
if [ ! "$a" ]; then
ssh -fN -R 19999:localhost:22 <middle-usename>@<middle-hostname>
Would really appreciate some help on this, pls.