ssh: breakout ups ssh to its own package

This was done for clearer separation of function. A subsequent update will (hopefully) make the SSL command more robust so it works for both NMC2 and NMC3.

The method for sending shell commands was also updated to use an interactive shell instead. This allows capturing responses of the commands which will be needed to deduce if devices are NMC2 or NMC3.
This commit is contained in:
Greg T. Wallace 2024-06-06 22:51:12 -04:00
parent 41efc56c62
commit 06c9263bc4
11 changed files with 444 additions and 284 deletions
pkg/apcssh

15
pkg/apcssh/ssl.go Normal file
View file

@ -0,0 +1,15 @@
package apcssh
import "fmt"
// InstallSSLCert installs the specified p15 cert file on the UPS. This
// function currently only works on NMC2.
func (cli *Client) InstallSSLCert(keyCertP15 []byte) error {
// install NMC2 P15 file
err := cli.UploadSCP("/ssl/defaultcert.p15", keyCertP15, 0600)
if err != nil {
return fmt.Errorf("apcssh: ssl cert install: failed to send file to ups over scp (%w)", err)
}
return nil
}