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