@@ -17,7 +17,7 @@ import (
1717
1818func SSHAddress (state multistep.StateBag ) (string , error ) {
1919 sshIP := state .Get ("ssh_address" ).(string )
20- sshHostPort := 22
20+ sshHostPort := state . Get ( "ssh_port" ).( uint )
2121 return fmt .Sprintf ("%s:%d" , sshIP , sshHostPort ), nil
2222}
2323
@@ -114,10 +114,10 @@ func ExecuteGuestSSHCmd(state multistep.StateBag, cmd string) (stdout string, er
114114 return doExecuteSSHCmd (cmd , localAddress , sshConfig )
115115}
116116
117- func forward (local_conn net.Conn , config * gossh.ClientConfig , server , remote_dest string , remote_port uint ) error {
117+ func forward (local_conn net.Conn , config * gossh.ClientConfig , server string , server_ssh_port int , remote_dest string , remote_port uint ) error {
118118 defer local_conn .Close ()
119119
120- ssh_client_conn , err := gossh .Dial ("tcp" , server + ":22" , config )
120+ ssh_client_conn , err := gossh .Dial ("tcp" , fmt . Sprintf ( "%s:%d" , server , server_ssh_port ) , config )
121121 if err != nil {
122122 log .Printf ("local ssh.Dial error: %s" , err )
123123 return err
@@ -157,7 +157,7 @@ func forward(local_conn net.Conn, config *gossh.ClientConfig, server, remote_des
157157 return nil
158158}
159159
160- func ssh_port_forward (local_listener net.Listener , remote_port int , remote_dest , host , username , password string ) error {
160+ func ssh_port_forward (local_listener net.Listener , remote_port int , remote_dest , host string , host_ssh_port int , username , password string ) error {
161161
162162 config := & gossh.ClientConfig {
163163 User : username ,
@@ -176,7 +176,7 @@ func ssh_port_forward(local_listener net.Listener, remote_port int, remote_dest,
176176 }
177177
178178 // Forward to a remote port
179- go forward (local_connection , config , host , remote_dest , uint (remote_port ))
179+ go forward (local_connection , config , host , host_ssh_port , remote_dest , uint (remote_port ))
180180 }
181181
182182 return nil
0 commit comments