a99fa973ec4a3971f371dcc7ded9c21dd50b2f15
[ossec-hids.git] / debian / ossec-hids / var / ossec / agentless / ssh.exp
1 #!/usr/bin/env expect
2
3 # Agentless monitoring
4 #
5 # Copyright (C) 2009 Trend Micro Inc.
6 # All rights reserved.
7 #
8 # This program is a free software; you can redistribute it
9 # and/or modify it under the terms of the GNU General Public
10 # License (version 2) as published by the FSF - Free Software
11 # Foundation.
12
13 if {[string compare $pass "NOPASS"] == 0} {
14     source $sshnopasssrc
15     return
16 }
17
18 expect {
19     "WARNING: REMOTE HOST" {
20         send_user "\nERROR: RSA host key for '$hostname' has changed. Unable to access.\n"
21         exit 1;
22     }
23     "*sure you want to continue connecting*" {
24         send "yes\r"
25         expect "*assword:*" {
26             send "$pass\r"
27             source $sshloginsrc
28         }
29     }
30     "ssh: connect to host*" {
31         send_user "\nERROR: Unable to connect to remote host: $hostname .\n"
32         exit 1;
33     }
34     "no address associated with name" {
35         send_user "\nERROR: Unable to connect to remote host: $hostname .\n"
36         exit 1;
37     }
38     "*Connection refused*" {
39         send_user "\nERROR: Unable to connect to remote host: $hostname .\n"
40         exit 1;
41     }
42     "*Connection closed by remote host*" {
43         send_user "\nERROR: Unable to connect to remote host: $hostname .\n"
44         exit 1;
45     }
46     "*assword:*" {
47         send "$pass\r"
48         source $sshloginsrc
49     }
50     timeout {
51         send_user "\nERROR: Timeout while connecting to host: $hostname . \n"
52         exit 1;
53     }
54 }