Documentation
¶
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Base32 ¶
func Base32() string
Base32 returns a base32 encoded 20 byte string. This has a greater range than UUID() and is safe for use with filesystems. Base32 is rendered in uppercase for clarity and because it is case insensitive. Base32 depends on 40 bit chunks. 20 bytes exceeds UUID() randomness and is the closest. (15 would be insufficient to cover the same range.) Base32() is therefore superior to UUID() both in range of randomness and practicality. Returns an empty string if unable to read random data.
func SSH ¶
SSH sets up a secure shell connection to the target (user@host:PORT) and uses public key method from private key in pem ukey argument. The hkey parameter must be in "authorized_keys" format for hosts allowed (usually ecdsa-sha2-nistp256). It then attempts to create a Session calling Output to return only the standard output of that command.
Example ¶
package main
import (
"fmt"
"os"
"github.com/rwxrob/remote"
)
func main() {
ukey, _ := os.ReadFile(`testdata/blahpriv`)
hkey, _ := os.ReadFile(`testdata/hostpubkey`)
stdout, stderr, err := remote.SSH(`blah@localhost:22`, ukey, hkey, `cat`, `hello`)
fmt.Printf("STDOUT\n%v\n", stdout)
fmt.Printf("STDERR\n%v\n", stderr)
fmt.Printf("ERROR\n%v\n", err)
}
Output: ignored
Types ¶
type Output ¶
Output is meant to contain the delimited sections of output and can be marshalled into a single delimited string safely and automatically simply by using it in a string context.
func (Output) MarshalText ¶
MarshalText fulfills the encoding.TextMarshaler interface by delimiting each section of output with a unique delimiter line that contains a space and the key for each section. Order of sections is indeterminate officially (but consistent for testing, per Go). The special "end" delimiter is always the last line.
func (Output) UnmarshalText ¶
UnmarshalText fulfills the encoding.TextUnmarshaler interface by sensing the delimiter as the first text field (up to the first space) and using that delimiter to parse the remaining data into the key/value pairs ending when either the end of text is encountered or the special "end" delimiter is read.