Who has ssh access?

0 like 0 dislike
15 views
As a team view the users which have SSH access?
by | 15 views

2 Answers

0 like 0 dislike
It has access to the users listed in /etc/passwd with a valid shell.
Something like this:
cat /etc/passwd | grep -E '/bin/(bash|sh)$' | grep -Eo '^\\w+'

This is an example for the popular shells (bash and sh), they are all listed in /etc/shells.

UPD: in this version scans all active Shelah in the system (thanks to Boris semov for the comments)
while read SHELL; do cat /etc/passwd | grep -E "$SHELL$" | grep -Eo '^\\w+'; done < /etc/shells
by
0 like 0 dislike
look in /etc/passwd one as the shell specified shell. For example
grep "sh" /etc/passwd
by

Related questions

0 like 0 dislike
3 answers
asked Apr 11, 2019 by html_profi
0 like 0 dislike
3 answers
0 like 0 dislike
2 answers
0 like 0 dislike
3 answers
110,608 questions
257,186 answers
0 comments
33,964 users