MCPcopy Create free account
hub / github.com/Mister-leo/fssh / analyzeKeyFile

Function analyzeKeyFile

cmd/fssh/setup_keys.go:251–276  ·  view source on GitHub ↗

analyzeKeyFile analyzes a potential SSH key file

(path string)

Source from the content-addressed store, hash-verified

249
250// analyzeKeyFile analyzes a potential SSH key file
251func analyzeKeyFile(path string) *SSHKeyInfo {
252 data, err := os.ReadFile(path)
253 if err != nil {
254 return nil
255 }
256
257 // Try to parse as private key
258 _, err = ssh.ParseRawPrivateKey(data)
259
260 info := &SSHKeyInfo{
261 Path: path,
262 Filename: filepath.Base(path),
263 }
264
265 if err != nil {
266 // Check if it's an encrypted key
267 if _, ok := err.(*ssh.PassphraseMissingError); ok {
268 info.IsEncrypted = true
269 } else {
270 // Not a valid private key
271 return nil
272 }
273 }
274
275 return info
276}
277
278// generateAlias generates a suggested alias from the filename
279func generateAlias(filename string) string {

Callers 1

scanSSHDirectoryFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected