Linux: Telnet / SSH

0

we've got an old ERP system running on RedHat 5. Now we need to force users to use SSH instead of TELNET, but we can't turn off TELNET now. Is there some command to display, who is connected via TELNET and who is connected via SSH? I tried it with PS, but it doesn't work. Thank you

polikit

Posted 2019-02-11T06:11:18.653

Reputation: 1

1

In my Debian sshd forks and there will be at least one sshd process owned by my user if I connect via SSH. So sudo pgrep -U kamil ^sshd$ will show something; otherwise nothing (and non-zero exit status). The command gives a false positive for user (root in my case) that runs the sshd daemon main process. I don't use telnet, so I cannot give you a good full answer, therefore just a comment. If this hint leads you to a useful solution then please add your own answer.

– Kamil Maciorowski – 2019-02-11T07:06:01.140

Answers

0

Finally I have the solution:

ps auxwww | grep driver | grep -v root | sort | awk '{print $1;}' > users_a.tmp
ps auxwww | grep ssh | grep pts | grep -v grep | sort | awk '{print $1;}' > users_b.tmp
echo "TELNET:"
comm -13 users_b.tmp users_a.tmp 
echo "SSH:"
cat users_b.tmp

polikit

Posted 2019-02-11T06:11:18.653

Reputation: 1

It would be better to save the output of ps auxwww and parse the saved copy twice; otherwise you may get incoherent results. It shouldn't be a (big) problem in your case, but in general it may. – Kamil Maciorowski – 2019-02-12T07:03:54.873