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

added DialWithConnection function #13

Merged
merged 1 commit into from
Apr 26, 2024

Conversation

sz-po
Copy link
Contributor

@sz-po sz-po commented Jun 10, 2022

In case of connecting through a bastion host, it is necessary to allow dial using existing net.Conn.

Look: https://stackoverflow.com/questions/35906991/go-x-crypto-ssh-how-to-establish-ssh-connection-to-private-instance-over-a-ba

@helloyi
Copy link
Owner

helloyi commented Jun 13, 2022

I think it would be more reasonable to add a Client.Dial(network, addr string, config *ssh.ClientConfig) (*Client, error).

The reasons are as follows:

  1. Consistent with the semantics of the ssh package, the difference is that the sshclient package does a top-level encapsulation and returns the Client object.
  2. Client.DialWithPasswd(addr, user, passwd string) (*Client, error) and other Dial* methods can be extended more flexibly and consistently.

Based on the above, to ensure the simplicity of sshclient.

@helloyi
Copy link
Owner

helloyi commented Jul 7, 2022

Client.Dial(network, addr string, config *ssh.ClientConfig) (*Client, error) has been added.

@helloyi helloyi closed this Jul 7, 2022
@Aaron-cdx
Copy link

hi @helloyi for this PR, I think it should be merged because for current code usage can't support connecting to the socks5 proxy and then connecting to the server.

client0, err := Dial("tcp", "host:port", config{})
if err != nil {
  handleErr(err)
}
defer client0.Close()

client, err := client0.Dail("tcp", "host:port", config{})
if err != nil {
  handleErr(err)
}
defer client.Close()

but if merge this PR, we can pass the conn which is dialed by socks5 proxy, which can help us connect the server successfully.
Can you help me if you have time? Because I am using your library now and our proxy is socks5. Thanks!

@helloyi helloyi reopened this Apr 26, 2024
@helloyi helloyi merged commit 334a88f into helloyi:master Apr 26, 2024
@helloyi
Copy link
Owner

helloyi commented Apr 26, 2024

I feel the power of DialWithConnection!
Thanks @sz-po !

@helloyi
Copy link
Owner

helloyi commented Apr 26, 2024

@Aaron-cdx
Would you provide an example of how you use DialWithConnection?
Please add usage examples to README.
Thanks!

@Aaron-cdx
Copy link

hi @helloyi Okay, I'll submit a PR later for this.

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

Successfully merging this pull request may close these issues.

3 participants