Skip to content

add connecting to custom port#30

Closed
mhbahmani wants to merge 4 commits into
melbahja:masterfrom
mhbahmani:master
Closed

add connecting to custom port#30
mhbahmani wants to merge 4 commits into
melbahja:masterfrom
mhbahmani:master

Conversation

@mhbahmani

Copy link
Copy Markdown

No description provided.

@mhbahmani mhbahmani closed this Jan 20, 2022
@mhbahmani

Copy link
Copy Markdown
Author

Closes #29

@mhbahmani mhbahmani reopened this Jan 20, 2022
@melbahja

Copy link
Copy Markdown
Owner

Can you use net.SplitHostPort ? and make the default port 22

@mhbahmani

Copy link
Copy Markdown
Author

Now check it out please.

@SegFault42

Copy link
Copy Markdown

Possible to merge it please ?

@melbahja

Copy link
Copy Markdown
Owner

This will break v1, it's gonna be in v2

Alternately if you want to connect to a custom port u can do:

user := "user"
addr := "127.0.0.1"
port := 22
// auth := your auth 

callback, err := goph.DefaultKnownHosts()
if err != nil {
   // handle err
}

client, err := goph.NewConn(&goph.Config{
  User:     user,
  Addr:     addr,
  Port:     port,
  Auth:     auth,
  Timeout:  goph.DefaultTimeout,
  Callback: callback,
})

@melbahja

Copy link
Copy Markdown
Owner

the new v2 has options api WithPort, please see:
https://pkg.go.dev/github.com/melbahja/goph/v2#WithPort

Thanks

@melbahja melbahja closed this Jul 15, 2026
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