Documentation
¶
Index ¶
- func GetCommonUserPublicKeys(ctx context.Context, fileSystem fs.FS) ([]string, error)
- func GetFileSystemPublicKeys(ctx context.Context, fileSystem fs.FS) ([]string, error)
- func LocalUserSSHFileSystem() fs.FS
- func MakeAuthorizedKeysString(keys []string) string
- func SplitAuthorizedKeys(keyData string) ([]string, error)
- func SplitAuthorizedKeysByDelimiter(delimiter byte, keyData string) ([]string, error)
- func SplitAuthorizedKeysReader(reader io.Reader) ([]string, error)
- func SplitAuthorizedKeysReaderByDelimiter(delimiter byte, reader io.Reader) ([]string, error)
- func WriteAuthorizedKeys(writer io.Writer, keys []string)
- type PublicKey
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetCommonUserPublicKeys ¶
GetCommonUserPublicKeys is responsible for attempting to load common public key files from the supplied file system. See LocalUserSSHFileSystem for accessing the users ssh file system.
The files target by this function are: - id_ed25519.pub - id_ecdsa.pub - id_rsa.pub - identity.pub
No attempt is made to verify the contents of each file is a valid ssh public key. Access errors to files such as permission or not found are ignored. Any other read based errors are returned.
func GetFileSystemPublicKeys ¶
GetFileSystemPublicKeys will attempt to find all ssh public keys at the root of the file system and read them all into a slice of public ssh keys. No attempt is made to assert if a file contains a valid public key.
Public keys are found based on the file in the file system ending in a ".pub" suffix. If a file is read and a permission error or file not found error occurs this function will simply move on and not report the problem upwards. This is a best effort approach.
This function is useful for reading the public keys found in a users juju ssh directory. See github.com/juju/juju/juju/osenv.JujuXDGDataSSHFS.
func LocalUserSSHFileSystem ¶
LocalUserSSHFileSystem returns a file system rooted at the local users .ssh directory.
func MakeAuthorizedKeysString ¶
MakeAuthorizedKeysString is responsible for turning a slice of public ssh keys into a compliant authorized key file string. Keys are written in the order they are defined in the keys slice.
No validation is performed on the keys to make sure they are public ssh keys.
func SplitAuthorizedKeys ¶
SplitAuthorizedKeys extracts a key slice from the specified key data, by splitting the key data into lines and ignoring comments and blank lines.
No validation is performed on the split keys to make sure they are compliant.
func SplitAuthorizedKeysByDelimiter ¶
SplitAuthorizedKeysByDelimiter extracts a key slice from the specified key data, by splitting the key data into lines separated by delimiter and ignoring comments and blank lines.
No validation is performed on the split keys to make sure they are compliant.
func SplitAuthorizedKeysReader ¶
SplitAuthorizedKeysReaderByDelimiter is responsible for splitting up all of the authorized keys contained within the reader into a slice of keys.
Keys in the reader are parsed in accordance with the open ssh authorized_keys file format.
Any errors encountered when reading from the reader are returned to the caller with exception of io.EOF.
No validation is performed on the split keys to make sure they are compliant.
func SplitAuthorizedKeysReaderByDelimiter ¶
SplitAuthorizedKeysReaderByDelimiter is responsible for splitting up all of the authorized keys contained within the reader into a slice of keys. The delimiter tells the parser what to use when considering a newline.
Keys in the reader are parsed in accordance with the open ssh authorized_keys file format.
Any errors encountered when reading from the reader are returned to the caller with exception of io.EOF.
No validation is performed on the split keys to make sure they are compliant.
func WriteAuthorizedKeys ¶
WriteAuthorizedKeys is responsible for writing a slice of authorized ssh public keys to a write as a standards compliant authorized keys file. Keys are written in the order they are defined in the keys slice.
No validation is performed on the keys to make sure they are public ssh keys.
Types ¶
type PublicKey ¶
type PublicKey struct { // Key holds the parse key data for the public key. Key ssh.PublicKey // Comment is the comment string attached to the authorised key. Comment string }
PublicKey represents a single authorised key line that would commonly be found in a authorized_keys file. http://man.he.net/man5/authorized_keys
func ParsePublicKey ¶
ParsePublicKey parses a single line from an authorised keys file returning a PublicKey representation of the data. ssh.ParseAuthorizedKey is used to perform the underlying validating and parsing.
func (*PublicKey) Fingerprint ¶
Fingerprint returns the SHA256 fingerprint of the public key.
Directories
¶
Path | Synopsis |
---|---|
Package importer provides a means for importing public ssh keys from a well known internet based location such as Github or Launchpad.
|
Package importer provides a means for importing public ssh keys from a well known internet based location such as Github or Launchpad. |