@@ -5,16 +5,21 @@ filter {
55 id => "ssh_login"
66 tag_on_failure => ["_grokparsefaillure","ssh_login_grok_failed"]
77 add_field => {
8- "[ssh][eventtype]" => "ssh_authentication "
8+ "[ssh][eventtype]" => "ssh_accepted_connection "
99 }
10- }
10+ }
11+ if [ssh][auth][result] == "Failed" {
12+ mutate {
13+ replace => { "[ssh][eventtype]" => "ssh_suspicious_connection" }
14+ }
15+ }
1116 } else if [message] =~ /^Invalid/ {
1217 grok {
13- match => ["message","%{DATA:[ssh][auth][event ]} user %{USERNAME:[user][name]} from %{IPORHOST:[client][address]}"]
18+ match => ["message","%{DATA:[ssh][auth][result ]} user %{USERNAME:[user][name]} from %{IPORHOST:[client][address]}"]
1419 id => "ssh_login_suspection"
1520 tag_on_failure => ["_grokparsefaillure","ssh_login_suspection_grok_failed"]
1621 add_field => {
17- "[ssh][eventtype]" => "ssh_invalid_login "
22+ "[ssh][eventtype]" => "ssh_suspicious_connection "
1823 }
1924 }
2025 } else if [message] =~ /pam_unix/ {
@@ -29,13 +34,41 @@ filter {
2934 } else if [message] =~ /^Did not receive identification string/ {
3035 grok {
3136 match => ["message","Did not receive identification string from %{IPORHOST:[client][ip]} port %{NUMBER:[client][port]}"]
32- id => "ssh_monitoring_noidentstring "
33- tag_on_failure => ["_grokparsefaillure","ssh_monitoring_noidentstring_grok_failed "]
37+ id => "ssh_noidentstring "
38+ tag_on_failure => ["_grokparsefaillure","ssh_noidentstring_grok_failed "]
3439 add_field => {
3540 "[ssh][eventtype]" => "ssh_noidentstring"
3641 }
3742 }
38- }
43+ } else if [message] =~ /(Received )?(d|D)isconnect(ed)? from/ {
44+ grok {
45+ match => ["message","%{DATA:[ssh][session][status]} from( user %{USERNAME:[user][name]})? %{IPORHOST:[client][ip]} port %{BASE10NUM:[client][port]}(disconnected by user)?"]
46+ id => "ssh_disconnected"
47+ tag_on_failure => ["_grokparsefaillure","ssh_disconnected_grok_failed"]
48+ add_field => {
49+ "[ssh][eventtype]" => "ssh_session_status"
50+ }
51+ }
52+ }
53+ else if [message] =~ /^Connection closed/ {
54+ grok {
55+ match => ["message","Connection %{DATA:[ssh][session][status]} by %{IPORHOST:[client][ip]} port %{BASE10NUM:[client][port]}"]
56+ id => "ssh_closed"
57+ tag_on_failure => ["_grokparsefaillure","ssh_connection_closed_grok_failed"]
58+ add_field => {
59+ "[ssh][eventtype]" => "ssh_session_status"
60+ }
61+ }
62+ } else if [message] =~ /error:/ {
63+ grok {
64+ match => ["message","error: %{DATA:[ssh][session_error]}: %{GREEDYDATA:[ssh][error_message]}"]
65+ id => "ssh_error"
66+ tag_on_failure => ["_grokparsefaillure","ssh_error_grok_failed"]
67+ add_field => {
68+ "[ssh][eventtype]" => "ssh_error"
69+ }
70+ }
71+ }
3972
4073 ## Copy client.address to the matching field according to ECS ##
4174
0 commit comments