Change initial directory based on port of reverse tunnel?

John givemefive at gmail.com
Fri Jan 24 19:20:39 EST 2014


Hello

I'm  trying to create compatibility with an automated system that I do
not have control over and cannot change. The system was built to
connect to individual embedded linux machines that create reverse
tunnels back to a server.

These tunnels take the form:
/bin/ssh -i /home/remote/.ssh/id_rsa -Nnx2TR 22000:127.0.0.1:22
robot at externalhost
/bin/ssh -i /home/remote/.ssh/id_rsa -Nnx2TR 22001:127.0.0.1:22
robot at externalhost
/bin/ssh -i /home/remote/.ssh/id_rsa -Nnx2TR 22002:127.0.0.1:22
robot at externalhost
/bin/ssh -i /home/remote/.ssh/id_rsa -Nnx2TR 22003:127.0.0.1:22
robot at externalhost

The bot then SCP copies from the home directory:
scp -i id_rsa -P 22000 remote at localhost:file.tar.gz

The major issue is that the Port is the identifying metric for the
home folder of the remote user. Each tunnel should have a different
folder because each folder represents a different physical location.
The system was setup with individual machines in mind.

Instead of SCP pulling from /home/remote, it should pull from
/home/remote22000, /home/remote22001, etc based on the port number of
the reverse tunnel.'

I'm not sure if there's anyway to get sshd to solve this problem
currently.  I'm open to all suggestions. I have spent a lot of time
reading man pages for openssh and nothing I have tried has worked so
far.

I found this post to the mailing list:
http://www.gossamer-threads.com/lists/openssh/dev/52909

If I made each tunnel listen on a different port then I could use that
to chroot each port to a different directory. I don't know if this is
the best approach.

I can't get the patch to work on a current version of openssh so if
that's the best solution I would need some help with that.

Thanks


More information about the openssh-unix-dev mailing list