On Tue, 2010-11-09 at 12:11 -0800, Jim Lucas wrote:
> On 11/9/2010 12:00 PM, Aaron Martinez wrote:
> >> On Tue, Nov 09, 2010 at 09:48:15AM -0600, Aaron Martinez wrote:
> >>> I am trying to use openbsd as my workstation here at work but one of the
> >>> tools we use, creates an expect script and it's not working at all. The
> >>> developer of the tool uses linux primarily so he's not sure except to
> >>> tell me that the expect in openbsd doesn't know spawn which I looked and
> >>> the expect man page is loaded with stuff about spawn.
> >>>
> >>> The script I try to run is this:
> >>> # cat 227254.test
> >>>
> >>> #!/usr/local/bin/expect -f
> >>> set timeout -1
> >>> spawn -noecho ssh -X -vvv -p 22 -o StrictHostKeyChecking=no -o \
> >>> UserKnownHostsFile=/dev/null -o GSSAPIAuthentication=no \
> >>> [email protected]
> >>> interact {
> >>> \034 exit
> >>> }
> >>>
> >>>
> >>> Executing this from the command line returns the following:
> >>>
> >>> # sh -x 227254.test
> >>
> >> When invoked like this, the interpreter is sh, not expect.
> >>
> >> --
> >>
> >> Will Maier
> >> http://will.m.aier.us/
> >>
> >>
> >
> >
> > Thanks Will,
> >
> > silly question, how would then I do a good test?
> >
> > Thanks.
> >
> > Aaron
> >
>
> # chmod 0744 227254.test
> # ./227254.test
>
Ok,
I was able to test this simplified script and it works just fine when I
run it, the output is below. The problem arises when I try to execute
the full script which is:
$ cat expect_full.test
#!/usr/local/bin/expect -f
set timeout -1
spawn -noecho ssh -X -vvv -p 22 -l test -o StrictHostKeyChecking=no \
-o UserKnownHostsFile=/dev/null -o GSSAPIAuthentication=no 192.168.0.10
match_max 100000
expect "assword"
sleep .1
send -- "tester\r"
expect {
-re "]|test|\$"
}
sleep .1
send -- "export LANG=en_US.UTF-8\r"
expect -re "]|test|\$"
sleep .1
send -- "su -\r"
expect "assword"
sleep .1
send -- "root_tester\r"
expect -re "#|assword|root|ROOT|%"
sleep .1
send -- "export LANG=en_US.UTF-8\r"
expect -re "]|root|#"
sleep .1
trap { stty rows [stty rows] columns [stty columns] \
< $spawn_out(slave,name)} WINCH
interact {
\034 exit
}
----------------------------------------------
I get brought back to what looks to be a password prompt but then when i
try to type a password it actually prints whatever I type right on the
screen. Hitting enter does nothing and the session just sits there
indefinitely.
Just a bit more information, I am connecting from an OpenBSD 4.8 system
to a RedHat 5.5 system.
The output when executing the full script is also below.
Output from simple script:
$ ./expect_simple_ssh_verbose.test
OpenSSH_5.6, OpenSSL 0.9.8k 25 Mar 2009
debug1: Reading configuration data /home/apmartinez/.ssh/config
debug1: Reading configuration data /etc/ssh/ssh_config
debug2: ssh_connect: needpriv 0
debug1: Connecting to 192.168.0.10 [192.168.0.10] port 22.
debug1: Connection established.
debug1: identity file /home/apmartinez/.ssh/id_rsa type -1
debug1: identity file /home/apmartinez/.ssh/id_rsa-cert type -1
debug1: identity file /home/apmartinez/.ssh/id_dsa type -1
debug1: identity file /home/apmartinez/.ssh/id_dsa-cert type -1
debug1: Remote protocol version 2.0, remote software version OpenSSH_4.3
debug1: match: OpenSSH_4.3 pat OpenSSH_4*
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_5.6
debug2: fd 5 setting O_NONBLOCK
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug2: kex_parse_kexinit:
diffie-hellman-group-exchange-sha256,diffie-hellman-group-exchange-sha1,diffie-hellman-group14-sha1,diffie-hellman-group1-sha1
debug2: kex_parse_kexinit:
[email protected],[email protected],[email protected],[email protected],ssh-rsa,ssh-dss
debug2: kex_parse_kexinit:
aes128-ctr,aes192-ctr,aes256-ctr,arcfour256,arcfour128,aes128-cbc,3des-cbc,blowfish-cbc,cast128-cbc,aes192-cbc,aes256-cbc,arcfour,[email protected]
debug2: kex_parse_kexinit:
aes128-ctr,aes192-ctr,aes256-ctr,arcfour256,arcfour128,aes128-cbc,3des-cbc,blowfish-cbc,cast128-cbc,aes192-cbc,aes256-cbc,arcfour,[email protected]
debug2: kex_parse_kexinit:
hmac-md5,hmac-sha1,[email protected],hmac-ripemd160,[email protected],hmac-sha1-96,hmac-md5-96
debug2: kex_parse_kexinit:
hmac-md5,hmac-sha1,[email protected],hmac-ripemd160,[email protected],hmac-sha1-96,hmac-md5-96
debug2: kex_parse_kexinit: none,[email protected],zlib
debug2: kex_parse_kexinit: none,[email protected],zlib
debug2: kex_parse_kexinit:
debug2: kex_parse_kexinit:
debug2: kex_parse_kexinit: first_kex_follows 0
debug2: kex_parse_kexinit: reserved 0
debug2: kex_parse_kexinit:
diffie-hellman-group-exchange-sha1,diffie-hellman-group14-sha1,diffie-hellman-group1-sha1
debug2: kex_parse_kexinit: ssh-rsa,ssh-dss
debug2: kex_parse_kexinit:
aes128-cbc,3des-cbc,blowfish-cbc,cast128-cbc,arcfour128,arcfour256,arcfour,aes192-cbc,aes256-cbc,[email protected],aes128-ctr,aes192-ctr,aes256-ctr
debug2: kex_parse_kexinit:
aes128-cbc,3des-cbc,blowfish-cbc,cast128-cbc,arcfour128,arcfour256,arcfour,aes192-cbc,aes256-cbc,[email protected],aes128-ctr,aes192-ctr,aes256-ctr
debug2: kex_parse_kexinit:
hmac-md5,hmac-sha1,hmac-ripemd160,[email protected],hmac-sha1-96,hmac-md5-96
debug2: kex_parse_kexinit:
hmac-md5,hmac-sha1,hmac-ripemd160,[email protected],hmac-sha1-96,hmac-md5-96
debug2: kex_parse_kexinit: none,[email protected]
debug2: kex_parse_kexinit: none,[email protected]
debug2: kex_parse_kexinit:
debug2: kex_parse_kexinit:
debug2: kex_parse_kexinit: first_kex_follows 0
debug2: kex_parse_kexinit: reserved 0
debug2: mac_setup: found hmac-md5
debug1: kex: server->client aes128-ctr hmac-md5 none
debug2: mac_setup: found hmac-md5
debug1: kex: client->server aes128-ctr hmac-md5 none
debug1: SSH2_MSG_KEX_DH_GEX_REQUEST(1024<1024<8192) sent
debug1: expecting SSH2_MSG_KEX_DH_GEX_GROUP
debug2: dh_gen_key: priv key bits set: 128/256
debug2: bits set: 492/1024
debug1: SSH2_MSG_KEX_DH_GEX_INIT sent
debug1: expecting SSH2_MSG_KEX_DH_GEX_REPLY
debug3: check_host_in_hostfile: host 192.168.0.10 filename /dev/null
debug3: check_host_in_hostfile: host 192.168.0.10 filename /dev/null
debug3: check_host_in_hostfile: host 192.168.0.10
filename /etc/ssh/ssh_known_hosts
debug3: check_host_in_hostfile: host 192.168.0.10
filename /etc/ssh/ssh_known_hosts
Warning: Permanently added '192.168.0.10' (RSA) to the list of known
hosts.
debug2: bits set: 513/1024
debug1: ssh_rsa_verify: signature correct
debug2: kex_derive_keys
debug2: set_newkeys: mode 1
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug2: set_newkeys: mode 0
debug1: SSH2_MSG_NEWKEYS received
debug1: Roaming not allowed by server
debug1: SSH2_MSG_SERVICE_REQUEST sent
debug2: service_accept: ssh-userauth
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug2: key: /home/apmartinez/.ssh/id_rsa (0x0)
debug2: key: /home/apmartinez/.ssh/id_dsa (0x0)
debug1: Authentications that can continue: publickey,password
debug3: start over, passed a different list publickey,password
debug3: preferred publickey,keyboard-interactive,password
debug3: authmethod_lookup publickey
debug3: remaining preferred: keyboard-interactive,password
debug3: authmethod_is_enabled publickey
debug1: Next authentication method: publickey
debug1: Trying private key: /home/apmartinez/.ssh/id_rsa
debug3: no such identity: /home/apmartinez/.ssh/id_rsa
debug1: Trying private key: /home/apmartinez/.ssh/id_dsa
debug3: no such identity: /home/apmartinez/.ssh/id_dsa
debug2: we did not send a packet, disable method
debug3: authmethod_lookup password
debug3: remaining preferred: ,password
debug3: authmethod_is_enabled password
debug1: Next authentication method: password
[email protected]'s password:
debug3: packet_send2: adding 48 (len 61 padlen 19 extra_pad 64)
debug2: we sent a password packet, wait for reply
debug1: Authentication succeeded (password).
Authenticated to 192.168.0.10 ([192.168.0.10]:22).
debug1: channel 0: new [client-session]
debug3: ssh_session2_open: channel_new: 0
debug2: channel 0: send open
debug1: Entering interactive session.
debug2: callback start
debug2: x11_get_proto: /usr/X11R6/bin/xauth
-f /tmp/ssh-nRvRxAN2w5/xauthfile generate :0.0 MIT-MAGIC-COOKIE-1
untrusted timeout 1200 2>/dev/null
Warning: untrusted X11 forwarding setup failed: xauth key data not
generated
Warning: No xauth data; using fake authentication data for X11
forwarding.
debug1: Requesting X11 forwarding with authentication spoofing.
debug2: channel 0: request x11-req confirm 0
debug2: client_session2_setup: id 0
debug2: channel 0: request pty-req confirm 1
debug2: channel 0: request shell confirm 1
debug2: fd 5 setting TCP_NODELAY
debug2: callback done
debug2: channel 0: open confirm rwindow 0 rmax 32768
debug1: Remote: No xauth program; cannot forward with spoofing.
debug2: channel_input_status_confirm: type 99 id 0
debug2: PTY allocation request accepted on channel 0
debug2: channel 0: rcvd adjust 2097152
debug2: channel_input_status_confirm: type 99 id 0
debug2: shell request accepted on channel 0
Last login: Sat Nov 13 10:05:12 2010 from lab1.proficuous.com
[t...@slave1 ~]$
[t...@slave1 ~]$ exit
logout
debug1: client_input_channel_req: channel 0 rtype exit-status reply 0
debug2: channel 0: rcvd eof
debug2: channel 0: output open -> drain
debug2: channel 0: obuf empty
debug2: channel 0: close_write
debug2: channel 0: output drain -> closed
debug2: channel 0: rcvd close
debug2: channel 0: close_read
debug2: channel 0: input open -> closed
debug3: channel 0: will not send data after close
debug2: channel 0: almost dead
debug2: channel 0: gc: notify user
debug2: channel 0: gc: user detached
debug2: channel 0: send close
debug2: channel 0: is dead
debug2: channel 0: garbage collecting
debug1: channel 0: free: client-session, nchannels 1
debug3: channel 0: status: The following connections are open:
#0 client-session (t4 r0 i3/0 o3/0 fd -1/-1 cc -1)
debug3: channel 0: close_fds r -1 w -1 e 8
Connection to 192.168.0.10 closed.
Transferred: sent 2064, received 2504 bytes, in 368.4 seconds
Bytes per second: sent 5.6, received 6.8
debug1: Exit status 0
Output from full script:
$ ./expect_full_ssh_verbose.test
OpenSSH_5.6, OpenSSL 0.9.8k 25 Mar 2009
debug1: Reading configuration data /home/apmartinez/.ssh/config
debug1: Reading configuration data /etc/ssh/ssh_config
debug2: ssh_connect: needpriv 0
debug1: Connecting to 192.168.0.10 [192.168.0.10] port 22.
debug1: Connection established.
debug1: identity file /home/apmartinez/.ssh/id_rsa type -1
debug1: identity file /home/apmartinez/.ssh/id_rsa-cert type -1
debug1: identity file /home/apmartinez/.ssh/id_dsa type -1
debug1: identity file /home/apmartinez/.ssh/id_dsa-cert type -1
debug1: Remote protocol version 2.0, remote software version OpenSSH_4.3
debug1: match: OpenSSH_4.3 pat OpenSSH_4*
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_5.6
debug2: fd 5 setting O_NONBLOCK
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug2: kex_parse_kexinit:
diffie-hellman-group-exchange-sha256,diffie-hellman-group-exchange-sha1,diffie-hellman-group14-sha1,diffie-hellman-group1-sha1
debug2: kex_parse_kexinit:
[email protected],[email protected],[email protected],[email protected],ssh-rsa,ssh-dss
debug2: kex_parse_kexinit:
aes128-ctr,aes192-ctr,aes256-ctr,arcfour256,arcfour128,aes128-cbc,3des-cbc,blowfish-cbc,cast128-cbc,aes192-cbc,aes256-cbc,arcfour,[email protected]
debug2: kex_parse_kexinit:
aes128-ctr,aes192-ctr,aes256-ctr,arcfour256,arcfour128,aes128-cbc,3des-cbc,blowfish-cbc,cast128-cbc,aes192-cbc,aes256-cbc,arcfour,[email protected]
debug2: kex_parse_kexinit:
hmac-md5,hmac-sha1,[email protected],hmac-ripemd160,[email protected],hmac-sha1-96,hmac-md5-96
debug2: kex_parse_kexinit:
hmac-md5,hmac-sha1,[email protected],hmac-ripemd160,[email protected],hmac-sha1-96,hmac-md5-96
debug2: kex_parse_kexinit: none,[email protected],zlib
debug2: kex_parse_kexinit: none,[email protected],zlib
debug2: kex_parse_kexinit:
debug2: kex_parse_kexinit:
debug2: kex_parse_kexinit: first_kex_follows 0
debug2: kex_parse_kexinit: reserved 0
debug2: kex_parse_kexinit:
diffie-hellman-group-exchange-sha1,diffie-hellman-group14-sha1,diffie-hellman-group1-sha1
debug2: kex_parse_kexinit: ssh-rsa,ssh-dss
debug2: kex_parse_kexinit:
aes128-cbc,3des-cbc,blowfish-cbc,cast128-cbc,arcfour128,arcfour256,arcfour,aes192-cbc,aes256-cbc,[email protected],aes128-ctr,aes192-ctr,aes256-ctr
debug2: kex_parse_kexinit:
aes128-cbc,3des-cbc,blowfish-cbc,cast128-cbc,arcfour128,arcfour256,arcfour,aes192-cbc,aes256-cbc,[email protected],aes128-ctr,aes192-ctr,aes256-ctr
debug2: kex_parse_kexinit:
hmac-md5,hmac-sha1,hmac-ripemd160,[email protected],hmac-sha1-96,hmac-md5-96
debug2: kex_parse_kexinit:
hmac-md5,hmac-sha1,hmac-ripemd160,[email protected],hmac-sha1-96,hmac-md5-96
debug2: kex_parse_kexinit: none,[email protected]
debug2: kex_parse_kexinit: none,[email protected]
debug2: kex_parse_kexinit:
debug2: kex_parse_kexinit:
debug2: kex_parse_kexinit: first_kex_follows 0
debug2: kex_parse_kexinit: reserved 0
debug2: mac_setup: found hmac-md5
debug1: kex: server->client aes128-ctr hmac-md5 none
debug2: mac_setup: found hmac-md5
debug1: kex: client->server aes128-ctr hmac-md5 none
debug1: SSH2_MSG_KEX_DH_GEX_REQUEST(1024<1024<8192) sent
debug1: expecting SSH2_MSG_KEX_DH_GEX_GROUP
debug2: dh_gen_key: priv key bits set: 121/256
debug2: bits set: 492/1024
debug1: SSH2_MSG_KEX_DH_GEX_INIT sent
debug1: expecting SSH2_MSG_KEX_DH_GEX_REPLY
debug3: check_host_in_hostfile: host 192.168.0.10 filename /dev/null
debug3: check_host_in_hostfile: host 192.168.0.10 filename /dev/null
debug3: check_host_in_hostfile: host 192.168.0.10
filename /etc/ssh/ssh_known_hosts
debug3: check_host_in_hostfile: host 192.168.0.10
filename /etc/ssh/ssh_known_hosts
Warning: Permanently added '192.168.0.10' (RSA) to the list of known
hosts.
debug2: bits set: 520/1024
debug1: ssh_rsa_verify: signature correct
debug2: kex_derive_keys
debug2: set_newkeys: mode 1
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug2: set_newkeys: mode 0
debug1: SSH2_MSG_NEWKEYS received
debug1: Roaming not allowed by server
debug1: SSH2_MSG_SERVICE_REQUEST sent
debug2: service_accept: ssh-userauth
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug2: key: /home/apmartinez/.ssh/id_rsa (0x0)
debug2: key: /home/apmartinez/.ssh/id_dsa (0x0)
debug1: Authentications that can continue: publickey,password
debug3: start over, passed a different list publickey,password
debug3: preferred publickey,keyboard-interactive,password
debug3: authmethod_lookup publickey
debug3: remaining preferred: keyboard-interactive,password
debug3: authmethod_is_enabled publickey
debug1: Next authentication method: publickey
debug1: Trying private key: /home/apmartinez/.ssh/id_rsa
debug3: no such identity: /home/apmartinez/.ssh/id_rsa
debug1: Trying private key: /home/apmartinez/.ssh/id_dsa
debug3: no such identity: /home/apmartinez/.ssh/id_dsa
debug2: we did not send a packet, disable method
debug3: authmethod_lookup password
debug3: remaining preferred: ,password
debug3: authmethod_is_enabled password
debug1: Next authentication method: password
tester
export LANG=en_US.UTF-8
su -
[email protected]'s password:
debug3: packet_send2: adding 64 (len 57 padlen 7 extra_pad 64)
debug2: we sent a password packet, wait for reply
debug1: Authentications that can continue: publickey,password
Permission denied, please try again.
[email protected]'s password:
Just a note, in my /home/apmartinez/.ssh/config file I have the line:
XAuthLocation /usr/X11R6/bin/xauth
Any ideas as to why the full script isn't working?
Thanks in advance.
Aaron