authorize_ssh_keys.go 390 B

123456789101112131415161718192021
  1. package cloudinit
  2. import (
  3. "os"
  4. "os/exec"
  5. log "github.com/Sirupsen/logrus"
  6. )
  7. func authorizeSSHKeys(user string, authorizedKeys []string, name string) {
  8. for _, authorizedKey := range authorizedKeys {
  9. cmd := exec.Command("update-ssh-keys", user, authorizedKey)
  10. cmd.Stdout = os.Stdout
  11. cmd.Stderr = os.Stderr
  12. err := cmd.Run()
  13. if err != nil {
  14. log.Fatal(err.Error())
  15. }
  16. }
  17. }