-
-
Notifications
You must be signed in to change notification settings - Fork 66
Closed
Description
Timeouts are adhered to when connecting directly to a server. Once a proxy is introduced, the timeout seems to be ignored.
package main
import (
"fmt"
"os"
"time"
"github.com/appleboy/easyssh-proxy"
"path/filepath"
)
func main() {
homedir, err := os.UserHomeDir()
if err != nil {
fmt.Printf("Error: %v\n", err)
}
keypath := filepath.Join(homedir, ".ssh", "id_rsa")
var easySSH *easyssh.MakeConfig
easySSH = &easyssh.MakeConfig{
User: "ec2-user",
Server: "1.2.3.4",
Port: "22",
KeyPath: keypath,
Timeout: 10 * time.Second,
Proxy: easyssh.DefaultConfig{
User: "ec2-user",
Server: "5.6.7.8",
Port: "22",
KeyPath: keypath,
Timeout: 10 * time.Second,
},
}
fmt.Printf("Connecting...\n")
timeStart := time.Now()
stdout, stderr, isTimeout, err := easySSH.Run("ls -la", 10 * time.Second)
timeEnd := time.Now()
fmt.Printf("stdout: %v\n", stdout)
fmt.Printf("stderr: %v\n", stderr)
fmt.Printf("isTimeout: %v\n", isTimeout)
fmt.Printf("err: %v\n", err)
fmt.Printf("Duration: %v\n", timeEnd.Sub(timeStart))
}
(Please note the that the hostnames, usernames, and key names have been changed as they contain identifying information.)
Output:
[devops@maintenance3 proxytest]$ go build . && ./proxytest
stdout:
stderr:
isTimeout: false
err: ssh: rejected: connect failed (Connection timed out)
Duration: 2m10.101925449s
I have verified connectivity to the proxy host.
Version information:
github.com/appleboy/easyssh-proxy v1.5.0
Metadata
Metadata
Assignees
Labels
No labels