Documentation
¶
Overview ¶
Package sshkeys provides SSH key handling functionality
Index ¶
- func CleanDuplicateKeys(filePath string) error
- func WriteToAuthorizedKeys(filePath string, keys []*Key, appendMode bool) error
- type Key
- func FetchFromGitHub(username string) ([]*Key, error)
- func FetchFromGitLab(username string) ([]*Key, error)
- func FetchFromURL(url string) ([]*Key, error)
- func ParseKeyString(keyString string, source Source, sourceValue string) (*Key, error)
- func ParseKeysFromText(text string) ([]*Key, error)
- func ReadFromFile(filePath string) ([]*Key, error)
- type Source
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CleanDuplicateKeys ¶
CleanDuplicateKeys reads an authorized_keys file and removes duplicate keys keeping only the first occurrence of each unique key (based on type and value, not comments)
Types ¶
type Key ¶
type Key struct {
// Content is the full content of the key
Content string
// Type is the key type (e.g., ssh-rsa, ssh-ed25519)
Type string
// Fingerprint is the key fingerprint
Fingerprint string
// Comment is the key comment (if any)
Comment string
// Source is where the key came from
Source Source
// SourceValue is the specific value for the source (e.g., GitHub username)
SourceValue string
}
Key represents an SSH public key with metadata
func FetchFromGitHub ¶
FetchFromGitHub fetches SSH keys from GitHub
func FetchFromGitLab ¶
FetchFromGitLab fetches SSH keys from GitLab
func FetchFromURL ¶
FetchFromURL fetches SSH keys from a URL
func ParseKeyString ¶
ParseKeyString parses a key string and returns a Key
func ParseKeysFromText ¶
ParseKeysFromText parses SSH keys from a text string
func ReadFromFile ¶
ReadFromFile reads SSH keys from a file
type Source ¶
type Source string
Source represents the source of an SSH key
const ( // GitHub represents GitHub as a key source GitHub Source = "github" // GitLab represents GitLab as a key source GitLab Source = "gitlab" // URL represents a direct URL as a key source URL Source = "url" // File represents a local file as a key source File Source = "file" // Text represents a direct text input as a key source Text Source = "text" )
Click to show internal directories.
Click to hide internal directories.