Hi,
So I have this command:
Code:
ssh -o User=myname -o ProxyCommand="ssh -W %h:%p myname@my-proxy-server" -L 1111:localhost:22 my-destination-server
This works great, but......when I try to put it into an expect script like so:
Code:
spawn ssh -o User=myname -o ProxyCommand="ssh -W \%h\:\%p myname@my-proxy-server" -L 1111:localhost:22 my-destination-server
I get the following error:
Code:
MacBook-Pro:bin myname$ ./myscript
Script configuration: username = bastion = host = appuser =
spawn ssh -o User=myname -o ProxyCommand="ssh -W %h:%p myname@my-proxy-server" -L 1111:localhost:22 my-destination-server
Bad stdio forwarding specification '%h:%p'
send: spawn id exp7 not open
while executing
"send "$password\n""
(file "./myscript" line 31)
This is line 31: send "$password\n"
Whole script for reference:
Code:
#!/usr/bin/expect
## This script ignores
trap {
set rows [stty rows]
set cols [stty columns]
stty rows $rows columns $cols < $spawn_out(slave,name)
} WINCH
set timeout -1
set SSH_OPT "-o PubkeyAuthentication=no -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no"
set username [lindex $argv 0]
set bastion [lindex $argv 1]
set host [lindex $argv 2]
set appuser [lindex $argv 3]
set passwordfile [open "~/.ssh/password" r]
set password [read $passwordfile]
close $passwordfile
send "Script configuration:\tusername = $username\tproxy = $proxy\thost = $host\tappuser = $appuser\n"
#works out side of script
#spawn ssh -o User=myname -o ProxyCommand="ssh -W \%h\:\%p myname@my-proxy-server" -L 1111:localhost:22 my-destination-server
# Throws error
#spawn ssh -o User="$username" -o ProxyCommand="ssh -W \%h\:\%p "$username\@$my-proxy-server" -L 1111:localhost:22 my-destination-server
#spawn ssh -o PubkeyAuthentication=no -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no "$username\@$my-proxy-server"
expect "password:"
send "$password\n"
interact
Any ideas?
Thanks.