apcssh: remove logging

For sanity and consistency, centralize logging in the app with the app's loggers.
This commit is contained in:
Greg T. Wallace 2024-06-06 22:51:13 -04:00
parent ce9958e422
commit 12c613f3b4
2 changed files with 6 additions and 7 deletions

View file

@ -4,9 +4,7 @@ import (
"crypto/sha256" "crypto/sha256"
"encoding/base64" "encoding/base64"
"encoding/hex" "encoding/hex"
"errors"
"fmt" "fmt"
"log"
"net" "net"
"runtime" "runtime"
"strings" "strings"
@ -57,10 +55,7 @@ func New(cfg *Config) (*Client, error) {
// check for fingerprint match (b64 or hex) // check for fingerprint match (b64 or hex)
if actualHashB64 != cfg.ServerFingerprint && actualHashHex != cfg.ServerFingerprint { if actualHashB64 != cfg.ServerFingerprint && actualHashHex != cfg.ServerFingerprint {
log.Printf("apcssh: remote server key fingerprint (b64): %s", actualHashB64) return fmt.Errorf("apcssh: server returned wrong fingerprint (b64: %s ; hex: %s)", actualHashB64, actualHashHex)
log.Printf("apcssh: remote server key fingerprint (hex): %s", actualHashHex)
return errors.New("apcssh: fingerprint didn't match")
} }
return nil return nil
@ -86,7 +81,6 @@ func New(cfg *Config) (*Client, error) {
// insecure cipher options? // insecure cipher options?
if cfg.InsecureCipher { if cfg.InsecureCipher {
log.Println("WARNING: insecure ciphers are enabled (--insecurecipher). SSH with an insecure cipher is NOT secure and should NOT be used.")
ciphers = append(ciphers, "aes128-cbc", "3des-cbc") ciphers = append(ciphers, "aes128-cbc", "3des-cbc")
} }

View file

@ -51,6 +51,11 @@ func (app *app) cmdInstall(cmdCtx context.Context, args []string) error {
return err return err
} }
// log warning if insecure cipher
if app.config.install.insecureCipher != nil && *app.config.install.insecureCipher {
app.stdLogger.Println("WARNING: install: insecure ciphers are enabled (--insecurecipher). SSH with an insecure cipher is NOT secure and should NOT be used.")
}
// make APC SSH client // make APC SSH client
cfg := &apcssh.Config{ cfg := &apcssh.Config{
Hostname: *app.config.install.hostAndPort, Hostname: *app.config.install.hostAndPort,