MCPcopy Create free account
hub / github.com/jetkvm/kvm / rpcSetSSHKeyState

Function rpcSetSSHKeyState

jsonrpc.go:475–500  ·  view source on GitHub ↗
(sshKey string)

Source from the content-addressed store, hash-verified

473}
474
475func rpcSetSSHKeyState(sshKey string) error {
476 if sshKey == "" {
477 // Remove SSH key file if empty string is provided
478 if err := os.Remove(sshKeyFile); err != nil && !os.IsNotExist(err) {
479 return fmt.Errorf("failed to remove SSH key file: %w", err)
480 }
481 return nil
482 }
483
484 // Validate SSH key
485 if err := utils.ValidateSSHKey(sshKey); err != nil {
486 return err
487 }
488
489 // Create directory if it doesn't exist
490 if err := os.MkdirAll(sshKeyDir, 0700); err != nil {
491 return fmt.Errorf("failed to create SSH key directory: %w", err)
492 }
493
494 // Write SSH key to file
495 if err := os.WriteFile(sshKeyFile, []byte(sshKey), 0600); err != nil {
496 return fmt.Errorf("failed to write SSH key: %w", err)
497 }
498
499 return nil
500}
501
502func rpcGetTLSState() TLSState {
503 return getTLSState()

Callers

nothing calls this directly

Calls 2

ValidateSSHKeyFunction · 0.92
ErrorfMethod · 0.80

Tested by

no test coverage detected