Mount remote filesystem through 2 SSH tunnels

2

As a university student, I am allowed to access my schools computers to work from home. However, it get there, i have to SSH to the university's general server, then SSH to the CIS departments server.

What I am trying to do is have access to the files on the CIS server that I can work on with a graphical text editor like gEdit.

In otherwords, I need to:

ssh general.server.com -l username 

then

ssh cis.server.com

and I want cis.server.com to be mounted.

Any help would be greatly appreciated.

binaryOne

Posted 2012-01-13T01:13:16.787

Reputation:

Answers

3

It's a little inefficient (systems are working harder), but you could forward a port via SSH to the internal box. Use the following to forward whatever port SSH is running on the internal server to any high port on your local machine.

ssh -C -f -g -N -x -L<localport>:<internalserver>:<port_you_run_ssh_on> username@gateway

You can then use sshfs to mount localhost at localport.

That'll give you a background SSH connection. I usually make an alias for the first part (up to the -x) so I don't have to type them in every time I need to set up a connection.

Alternatively, you can just use the above to set up an SSH tunnel and then ssh with X forwarding, or transfer the file via sftp to your local machine and edit.

If you just need to edit text files, consider learning how to use a console-based text editor (like Vim or Emacs)--they're nice, powerful, and have GUI versions that you can use later. Then just edit directly on the remote system. I prefer Vim myself.

Joseph Lenox

Posted 2012-01-13T01:13:16.787

Reputation:

2

In the ssh config of your client build a configuration.

Host aliasforsystem
    ProxyCommand /usr/bin/ssh username@general.server.com "/bin/netcat -w 1 cis.server.com 22"

Then just ssh to aliasforsystem. You should be able to mount that aliasdirectly. If you have ssh keys setup then it should be really simple. You do need the general system to have netcat or something similar installed though.

You could also build tunnels starting one connection with a portforward to the internal box. Leave that open, and then connect to the internal system via the port forward.

Zoredache

Posted 2012-01-13T01:13:16.787

Reputation: 18 453

The general server does not appear to have netcat installed. Could you list some alternatives that would work? – None – 2012-01-13T02:20:51.547

1

@binaryOne - You are a CS student I presume? Go download the netcat source, build it, & install it under your home directory. :-) (really, it's not as hard as you think it will be)

– voretaq7 – 2012-01-13T22:15:47.743