Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Timeout argument ignored when using proxy #93

Open
ascheel opened this issue Aug 23, 2024 · 1 comment
Open

Timeout argument ignored when using proxy #93

ascheel opened this issue Aug 23, 2024 · 1 comment

Comments

@ascheel
Copy link

ascheel commented Aug 23, 2024

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

@ascheel
Copy link
Author

ascheel commented Aug 23, 2024

Also I just noticed that the connection is not seen as a timeout (isTimeout: false)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant