1

I've created an SSH tunnel to a remote machine, with the local entry being a file socket, using -L /tmp/my.socket:127.0.0.1:22

Now how do I use ssh to connect to that file socket instead of a regular network host?

I'm doing this because I need to have many concurrent connections, each specific to a particular user, and I don't want other users to accidentally/intentionally connect to other users sockets. I have to connect this way, because I need to use a specific user to connect to the machine remotely, but can then connect as a non-privileged user, on localhost.

3

Using netcat as a ProxyCommand might work:

ssh -o ProxyCommand='nc -U /tmp/my.socket' some-host
  • Yes, the above works with <username>@localhost however it obviously complains that my known_hosts entry for localhost doesn't match. Any ideas how to get it to ignore that? – sibaz Jul 8 at 11:01
  • But testing the above <username>@<actual host> seems to work too (connecting via the socket), without complaining about the known_host issue, so this is defo a winner – sibaz Jul 8 at 11:02
  • @sibaz you can copy the actual host's key in known_hosts and add an entry for localhost with it. Hosts can have multiple keys in known_hosts. – muru Jul 8 at 11:09
  • problem with that is where you're proxying, localhost, isn't the local machine, so in the case I mentioned updating known_hosts to identify some other box, as localhost, is likely to cause other problems. Hence I wanted a way to have it ignore that. As mentioned, I found that even when connecting to a local socket, specifying username@<host>, will identify that socket (as far as known_hosts is concerned) as being <host>, which is a winner to my problem. – sibaz Sep 19 at 10:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.