I rely on the following script
tunnel.sh written by others to keep a ssh tunnel alive:
#!/bin/bash export SSH_HOST=tim@server if [ ! -f /tmp/.tunnel ] then echo "Creat SSH tunnel" ssh -f -D 9999 $SSH_HOST "if [ -f ~/.tunnel ]; then rm ~/.tunnel; fi; while [ ! -f ~/.tunnel ]; do echo > /dev/null; done" & touch /tmp/.tunnel else echo "Close SSH tunnel" ssh $SSH_HOST "touch ~/.tunnel" rm /tmp/.tunnel fi exit
To create a persistent ssh tunnel, I just issue
`tunnel.sh. The tunnel will not be closed until I issue
I was wondering how I can verify if the ssh tunnel is indeed created successfully?
My main use of the tunnel is to print documents to some printers in the same LAN as the server, and the printers can only be accessed from within the LAN. After creating a tunnel, now printing doesn't report any problem, but since I am not physically there, I cannot check if the documents have been indeed printed.
I thought since I am now in the LAN thanks to the tunnel, my external IP should be the same as the server's. But actually they are not the same (I found them out by
wget -q -O - checkip.dyndns.org|sed -e 's/.*Current IP Address: //' -e 's/<.*$//'
). I wonder why? When I connect to some website on the internet with the tunnel alive, isn't the server the midpoint between me and the internet website in the connection, due to the tunnel between me and the server?
Thanks and regards!