aboutsummaryrefslogtreecommitdiff
path: root/lib/ssh/client.go
diff options
context:
space:
mode:
authorShulhan <ms@kilabit.info>2023-09-26 18:41:13 +0700
committerShulhan <ms@kilabit.info>2023-09-26 18:41:13 +0700
commit8d0720f6f9406262868e2efa0d757ec27ef7119d (patch)
treec30fed676692f599834c991e69fb200c745d8c0c /lib/ssh/client.go
parent410ab868afb9bfc8c02cba67ca6e9c436b44061b (diff)
downloadpakakeh.go-8d0720f6f9406262868e2efa0d757ec27ef7119d.tar.xz
go.mod: remove replace directive for golang.org/x/crypto
Using replace directive does not works well if we install binary using "go install". One of the case that we found is when user installing awwan [1] that use "share" module [2] with replace directive, the binary is not build with git.sr.ht/~shulhan/go-x-crypto. /Users/xxx/go/bin/awwan: go1.21.0 path git.sr.ht/~shulhan/awwan/cmd/awwan mod git.sr.ht/~shulhan/awwan v0.7.1-0.20230925173020-40b9fe9b854c h1:629djcSfqM8ITX+CtgGyrybPnKQPpwJ/EceN967bKps= dep git.sr.ht/~shulhan/asciidoctor-go v0.5.0 h1:TfcAjv+7EwBZ83ef8OhX9vfQ4vRFcaJh0P1XXgbsJv0= dep git.sr.ht/~shulhan/ciigo v0.10.0 h1:s1SJ3/NzBcbOLmEZ4z1Cx9Vf7ZdDIvm45b7KMCZKzEY= dep github.com/evanw/esbuild v0.19.3 h1:foPr0xwQM3lBWKBtscauTN9FrmJzRDVI2+EGOs82H/I= dep github.com/shuLhan/share v0.49.2-0.20230923081600-77c41ce992e6 h1:REQDC2UKLaWT1WGd/Iw/rfKLkXb7vtKtyObkeZeHZRk= dep github.com/yuin/goldmark v1.5.6 h1:COmQAWTCcGetChm3Ig7G/t8AFAN00t+o8Mt4cf7JpwA= dep github.com/yuin/goldmark-meta v1.1.0 h1:pWw+JLHGZe8Rk0EGsMVssiNb/AaPMHfSRszZeUeiOUc= dep golang.org/x/crypto v0.13.0 h1:mvySKfSWJ+UKUii46M40LOvyWfN0s2U+46/jDd0e6Ck= dep golang.org/x/net v0.15.0 h1:ugBLEUaxABaB5AJqW9enI0ACdci2RUd4eP51NTBvuJ8= dep golang.org/x/sys v0.12.0 h1:CM0HF96J0hcLAwsHPJZjfdNzs0gftsLfgKt57wWHJ0o= dep golang.org/x/term v0.12.0 h1:/ZfYdc3zq+q02Rv9vGqTeSItdzZTSNDmfTi0mBAuidU= dep gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= build -buildmode=exe build -compiler=gc build DefaultGODEBUG=panicnil=1 build CGO_ENABLED=1 build CGO_CFLAGS= build CGO_CPPFLAGS= build CGO_CXXFLAGS= build CGO_LDFLAGS= build GOARCH=arm64 build GOOS=darwin This changes require use to modify lib/cryto and lib/ssh that depends on our patches. [1] https://git.sr.ht/~shulhan/awwan [2] https://github.com/shuLhan/share/commit/77c41ce992e6
Diffstat (limited to 'lib/ssh/client.go')
-rw-r--r--lib/ssh/client.go26
1 files changed, 11 insertions, 15 deletions
diff --git a/lib/ssh/client.go b/lib/ssh/client.go
index ae70163a..0f1ed680 100644
--- a/lib/ssh/client.go
+++ b/lib/ssh/client.go
@@ -5,13 +5,13 @@
package ssh
import (
- "errors"
"fmt"
"io"
"log"
"net"
"os"
"os/exec"
+ "strings"
"golang.org/x/crypto/ssh"
"golang.org/x/crypto/ssh/agent"
@@ -111,8 +111,7 @@ func NewClientInteractive(section *config.Section) (cl *Client, err error) {
return cl, nil
}
- var errKey *knownhosts.KeyError
- if errors.As(err, &errKey) {
+ if strings.Contains(err.Error(), `knownhosts`) {
// Host key is either unknown or mismatch with one
// of known_hosts files, so no need to continue with
// dialWithPrivateKeys.
@@ -175,19 +174,16 @@ func (cl *Client) setConfigHostKeyCallback() (err error) {
// dialError return the error with clear information when the host key is
// missing or mismatch from known_hosts files.
func (cl *Client) dialError(logp string, errDial error) (err error) {
- var (
- errKey *knownhosts.KeyError
- )
- if errors.As(errDial, &errKey) {
- if len(errKey.Want) == 0 {
- err = fmt.Errorf(`%s: %w: server host key is missing from %+v`, logp, errDial, cl.listKnownHosts)
- } else {
- err = fmt.Errorf(`%s: %w: server host key mismatch in %+v`, logp, errDial, cl.listKnownHosts)
- }
- } else {
- err = fmt.Errorf(`%s: %w`, logp, errDial)
+ var errDialString = errDial.Error()
+
+ if strings.Contains(errDialString, `key is unknown`) {
+ return fmt.Errorf(`%s: %w from known_hosts files %+v`, logp, errDial, cl.listKnownHosts)
}
- return err
+ if strings.Contains(errDialString, `key mismatch`) {
+ return fmt.Errorf(`%s: %w with known_hosts files %+v`, logp, errDial, cl.listKnownHosts)
+ }
+
+ return fmt.Errorf(`%s: %w`, logp, errDial)
}
// dialWithSigners connect to the remote machine using AuthMethod PublicKeys