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