0

I'm trying to create a setup where one could "ssh" to a specific port on localhost and then get forwarded to a remote server and into a shell, without the need to enter credentials (nope, secret key is not an option, unfortunately).

So far I have set up ssh multiplexing, with ControlMaster, so I can start a remote ssh shell without any prompts, from the local shell.

Is there a way to use that socket when new client connects to a specific port on localhost?

I've tried various combinations with -D, -R and -S, with no luck. Is such a setup possible, on either Linux or Mac?

edit:

I don't mind entering localhost credentials at any point, but I'm trying to avoid entering remote credentials for all connections following the initial control connection.


localhost        ---->    localhost:2222             ---->   remote:22
  $ ssh -p 2222             forward to remote                  $ _ :)
                            using an existing 
                            control socket
  • Well that sounds incredibly insecure. – Grant Sep 16 '14 at 17:10
  • If you want ssh without security it's called rsh. – yoonix Sep 16 '14 at 17:11
  • It shouldn't be insecure, because a) there needs to be an open control connection, and that requires credentials, and b) closing port 2222 for everything but local traffic should protect it just fine. – frnhr Sep 16 '14 at 17:13
0

If you want a basic shell, you could use netcat to create a shell listening on a certain port on remote server, and use Port Forwarding on local ssh to create the tunnels:

On remote:

while true ; do netcat -l -p 15000 -e /bin/bash ; done

On local:

ssh -L 5000:remoteip:15000 user@server
netcat localhost 5000

You will not be able to use some commands (vim behaviour is funny), but it works for most commands. Every time the connection is closed, the loop will spawn a new one.

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.