diff options
| author | Paul Buetow <pbuetow@mimecast.com> | 2024-02-23 15:01:41 +0200 |
|---|---|---|
| committer | Paul Buetow <pbuetow@mimecast.com> | 2024-03-29 17:16:39 +0200 |
| commit | 0f718c963e118139c893e9c52092e278bcd3b396 (patch) | |
| tree | dce61c6695bc3badd455a64767252e6947b32711 /internal/ssh | |
| parent | 7a0b0cde9c7c46d5f70ebc4a9d4f4e718d835f70 (diff) | |
lint warnings
Diffstat (limited to 'internal/ssh')
| -rw-r--r-- | internal/ssh/client/clientkeypair.go | 3 | ||||
| -rw-r--r-- | internal/ssh/client/knownhostscallback.go | 8 | ||||
| -rw-r--r-- | internal/ssh/server/hostkey.go | 5 | ||||
| -rw-r--r-- | internal/ssh/server/publickeycallback.go | 3 | ||||
| -rw-r--r-- | internal/ssh/ssh.go | 7 |
5 files changed, 13 insertions, 13 deletions
diff --git a/internal/ssh/client/clientkeypair.go b/internal/ssh/client/clientkeypair.go index b35b25d..20cdc88 100644 --- a/internal/ssh/client/clientkeypair.go +++ b/internal/ssh/client/clientkeypair.go @@ -6,7 +6,6 @@ import ( "crypto/x509" "encoding/pem" "fmt" - "io/ioutil" "os" "github.com/mimecast/dtail/internal/io/dlog" @@ -83,7 +82,7 @@ func generatePublicKey(privatekey *rsa.PublicKey) ([]byte, error) { } func writeKey(keyBytes []byte, saveFileTo string) error { - err := ioutil.WriteFile(saveFileTo, keyBytes, 0600) + err := os.WriteFile(saveFileTo, keyBytes, 0600) if err != nil { return err } diff --git a/internal/ssh/client/knownhostscallback.go b/internal/ssh/client/knownhostscallback.go index 393c4c7..fe3543c 100644 --- a/internal/ssh/client/knownhostscallback.go +++ b/internal/ssh/client/knownhostscallback.go @@ -232,8 +232,12 @@ func (c KnownHostsCallback) trustHosts(hosts []unknownHost) { // And once as [IP]:PORT addresses[knownhosts.Normalize(unknown.remote.String())] = struct{}{} - newFd.WriteString(fmt.Sprintf("%s\n", unknown.hostLine)) - newFd.WriteString(fmt.Sprintf("%s\n", unknown.ipLine)) + if _, err := newFd.WriteString(fmt.Sprintf("%s\n", unknown.hostLine)); err != nil { + panic(err) + } + if _, err := newFd.WriteString(fmt.Sprintf("%s\n", unknown.ipLine)); err != nil { + panic(err) + } } // Read old known hosts file, to see which are old and new entries diff --git a/internal/ssh/server/hostkey.go b/internal/ssh/server/hostkey.go index be23d85..b2d4569 100644 --- a/internal/ssh/server/hostkey.go +++ b/internal/ssh/server/hostkey.go @@ -1,7 +1,6 @@ package server import ( - "io/ioutil" "os" "github.com/mimecast/dtail/internal/config" @@ -26,7 +25,7 @@ func PrivateHostKey() []byte { } pem := ssh.EncodePrivateKeyToPEM(privateKey) - if err := ioutil.WriteFile(hostKeyFile, pem, 0600); err != nil { + if err := os.WriteFile(hostKeyFile, pem, 0600); err != nil { dlog.Server.Error("Unable to write private server RSA host key to file", hostKeyFile, err) } @@ -34,7 +33,7 @@ func PrivateHostKey() []byte { } dlog.Server.Info("Reading private server RSA host key from file", hostKeyFile) - pem, err := ioutil.ReadFile(hostKeyFile) + pem, err := os.ReadFile(hostKeyFile) if err != nil { dlog.Server.FatalPanic("Failed to load private server RSA host key", err) } diff --git a/internal/ssh/server/publickeycallback.go b/internal/ssh/server/publickeycallback.go index f7655b4..bcc9004 100644 --- a/internal/ssh/server/publickeycallback.go +++ b/internal/ssh/server/publickeycallback.go @@ -2,7 +2,6 @@ package server import ( "fmt" - "io/ioutil" "os" goUser "os/user" @@ -30,7 +29,7 @@ func PublicKeyCallback(c gossh.ConnMetadata, } dlog.Server.Info(user, "Reading", authorizedKeysFile) - authorizedKeysBytes, err := ioutil.ReadFile(authorizedKeysFile) + authorizedKeysBytes, err := os.ReadFile(authorizedKeysFile) if err != nil { return nil, fmt.Errorf("Unable to read authorized keys file|%s|%s|%s", authorizedKeysFile, user, err.Error()) diff --git a/internal/ssh/ssh.go b/internal/ssh/ssh.go index db5aaf1..9c2dcb8 100644 --- a/internal/ssh/ssh.go +++ b/internal/ssh/ssh.go @@ -6,7 +6,6 @@ import ( "crypto/x509" "encoding/pem" "fmt" - "io/ioutil" "net" "os" "syscall" @@ -15,7 +14,7 @@ import ( gossh "golang.org/x/crypto/ssh" "golang.org/x/crypto/ssh/agent" - "golang.org/x/crypto/ssh/terminal" + "golang.org/x/term" ) // GeneratePrivateRSAKey is used by the server to generate its key. @@ -63,7 +62,7 @@ func Agent() (gossh.AuthMethod, error) { // EnterKeyPhrase is required to read phrase protected private keys. func EnterKeyPhrase(keyFile string) []byte { fmt.Printf("Enter phrase for key %s: ", keyFile) - phrase, err := terminal.ReadPassword(int(syscall.Stdin)) + phrase, err := term.ReadPassword(int(syscall.Stdin)) if err != nil { panic(err) } @@ -73,7 +72,7 @@ func EnterKeyPhrase(keyFile string) []byte { // KeyFile returns the key as a SSH auth method. func KeyFile(keyFile string) (gossh.AuthMethod, error) { - buffer, err := ioutil.ReadFile(keyFile) + buffer, err := os.ReadFile(keyFile) if err != nil { return nil, err } |
