I'm often asked by friends to help with small Linux problems, and more often than not I'm required to login to the remote system. Usually there are a lot of issues with making an account and logging in (sometimes the box is behind a NAT device, sometimes SSHD isn't installed, etc.) so I usually just ask them to make a connect-back shell using netcat (nc -e /bin/bash ). If they don't have netcat I can just ask them to grab a copy of a statically compiled binary which isn't that hard or time consuming to download and run.

Though this works well enough for me to enter simple commands, I can't run any apps that require a tty (vi, for example) and can't use any job control functions. I managed to bypass this issue by running in.telnetd with a few arguments within the connect-back shell that would assign me a terminal and drop me to a shell. Unfortunately in.telnetd isn't usually installed by default on most systems.

What's the easiest way to get a fully functional connect-back terminal shell without requiring any non-standard packages?

(A small C program that does the job would be fine as well, I just can't seem to find much documentation on how a TTY is assigned/allocated. A solution that doesn't require me to plough through the source code for SSHD and TELNETD would be nice :))

link|improve this question

75% accept rate
SSHd (imho) should be considered a default package on any linux install, if your friend doesn't have it, then I'm guessing Ubuntu which does have VNC as default (System -> Preferences -> Remote Desktop). If we redefined your question as "How can I connect to SSH/VNC on a remote box behind NAT, when I can't configure port forwarding?" would that be OK for you, 'cos I can answer that pretty easily :) – MidnighToker Jan 14 '10 at 22:07
SSH reverse (port) forwarding FTW! – MidnighToker Jan 15 '10 at 4:55
feedback

1 Answer

It is not a standard program, but "socat tcp:your-host:1234 exec:bash,pty" will do the work.

You can also secure your communication with OpenSSL with socat:

# Your side:
openssl req -new -x509 -days 365 -nodes -out cert.pem -keyout cert.pem
socat `tty`,raw,echo=0 openssl-listen:1237,reuseaddr,cert=cert.pem,verify=0

# Their side:
socat openssl-connect:127.0.0.1:1237,verify=0 exec:bash,pty,stderr,setsid

This will provide nice connect-back terminal with encryption.

link|improve this answer
feedback

Your Answer

 
or
required, but never shown

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