Tuesday, August 7, 2012

connecting a tunnel to a reverse ssh connection and mounting with sshfs

I have a machine (treestump) that connects to a server with a known ip address (applecart). treestump opens a reverse proxy connection onto applecart at port 29999. From applecart, I can connect to treestump from applecart by issuing: 'ssh me@localhost -p 29999'. I have password less logins configured.

I'm on my machine here (rainplant). rainplant can't see treestump but does have an account and passwordless login to applecart. I want to mount treestump using sshfs. This requires two steps.

1. Set up a tunnel all the way through to treestump.
    ssh -L 127.0.0.1:1999:127.0.0.1:29999 me@applecart
1.a Test the connection.
    ssh me@localhost -p 1999
2 Mount using sshfs
    sshfs -p 1999 me@localhost:/storage/ ./treestumpstorage

I saw a suggestion to use autossh, this makes sense to me on treestump.