how to determine type of user's connection: SSH or telnet

7 views
Skip to first unread message

Michael Hughes

unread,
Dec 6, 2008, 2:30:32 PM12/6/08
to umu...@googlegroups.com
Hi UMUC LUG,

I have a challenge for you: despite the insecurity and pending
phase-out of telnet, a need to resolve the following has been
presented to me:
To set the backspace character for a remote terminal connection using
"stty erase '^h'", but only if the incoming connection is through
telnet.

A natural place to perform this would be in the .profile script, but I
haven't been able to find a value to query to determine if the
incoming connection is through telnet or SSH. Any help appreciated!

-Mike

--

Jim Bishop - "Golf is played by twenty million mature American men
whose wives think they are out having f...

Mark Hoffmeyer

unread,
Dec 7, 2008, 10:16:09 AM12/7/08
to UMUCLUG
Just off the top of my head,
who -a will show all the currently logged in users and the process ID
that was spawned by their login. grep or cut out that pid and that pid
should be a telnetd or the sshd...

Good Luck.

Michael Hughes

unread,
Dec 7, 2008, 5:16:47 PM12/7/08
to umu...@googlegroups.com
Hi Mark,

That helped a lot! I could use 'who -a', but also found that I can
get the same info from ps. But ps just returns the process for the
shell (sh), and the ps (ps) command, but it also has a switch called
'ppid' that displays the parent process. And from the parent, I see I
am connected through "sshd1":

$ ps
PID TTY TIME CMD
6629 pts/3 0:00 ps
3089 pts/3 0:00 sh

$ ps -o ppid
PPID
3056
3089

$ ps -p 3056
PID TTY TIME CMD
3056 ? 0:02 sshd1

I'll just string these together and make an if-statement if it sees telnet.

Thanks!
-Mike
--

Zsa Zsa Gabor - "A man in love is incomplete until he has married.
Then he's finished."
Reply all
Reply to author
Forward
0 new messages