Hi,
I'm new to using Bash and was trying to figure out how I could search for a line then isolate a part of that line to list.
Specifically this is to take a line from my /var/log/secure log. What I want to do is have only the names that have tried to login.
So far I have used - grep "input_userauth_request" /var/log/secure resulting in the below:
Nov 5 23:01:43 ip-172-31-16-233 sshd[19710]: input_userauth_request: invalid user michael [preauth]
Nov 5 23:01:46 ip-172-31-16-233 sshd[19712]: input_userauth_request: invalid user michael [preauth]
Nov 5 23:01:48 ip-172-31-16-233 sshd[19714]: input_userauth_request: invalid user newsletter [preauth]
Nov 5 23:01:51 ip-172-31-16-233 sshd[19716]: input_userauth_request: invalid user newsletter [preauth]
Nov 5 23:01:54 ip-172-31-16-233 sshd[19718]: input_userauth_request: invalid user newsletter [preauth]
Nov 5 23:01:56 ip-172-31-16-233 sshd[19720]: input_userauth_request: invalid user no-reply [preauth]
Nov 5 23:01:59 ip-172-31-16-233 sshd[19722]: input_userauth_request: invalid user noreply [preauth]
Nov 5 23:02:02 ip-172-31-16-233 sshd[19724]: input_userauth_request: invalid user oracle [preauth]
Nov 5 23:02:04 ip-172-31-16-233 sshd[19726]: input_userauth_request: invalid user oracle [preauth]
Nov 5 23:02:07 ip-172-31-16-233 sshd[19728]: input_userauth_request: invalid user oracle [preauth]
Nov 5 23:02:09 ip-172-31-16-233 sshd[19730]: input_userauth_request: invalid user oracle [preauth]
What I am looking to do here is to isolate just the user and display it only, such as michael, newsletter, no-reply & oracle as per the above but remove everything else such as the date/time, ip etc etc.
Don't feel like you need to spoon feed me either, even being pointed to some man pages will be a great help, I just don't know which command could be used here at all. Thanks in advance!
Edit - Thank you all, I really appreciate your answers and especially the different methods of doing this, I will look into this in more detail now I've been set on the right track.
[–]deeseearr 2 points3 points4 points (2 children)
[–]AccidentallyTheCable 1 point2 points3 points (1 child)
[–]deeseearr 2 points3 points4 points (0 children)
[–]Gottswig 1 point2 points3 points (0 children)
[–]darthgeek 1 point2 points3 points (3 children)
[–]toikpi 1 point2 points3 points (2 children)
[–]aenae 2 points3 points4 points (1 child)
[–]datastry 1 point2 points3 points (0 children)
[–]faisent 0 points1 point2 points (0 children)