2015-02-22 00:07:29 +00:00
|
|
|
package cloudinit
|
|
|
|
|
2015-02-23 18:58:43 +00:00
|
|
|
import (
|
|
|
|
"os"
|
2015-02-22 00:07:29 +00:00
|
|
|
"os/exec"
|
|
|
|
|
|
|
|
log "github.com/Sirupsen/logrus"
|
|
|
|
)
|
|
|
|
|
|
|
|
func authorizeSSHKeys(user string, authorizedKeys []string, name string) {
|
|
|
|
for _, authorizedKey := range authorizedKeys {
|
|
|
|
cmd := exec.Command("update-ssh-keys", user, authorizedKey)
|
2015-02-23 18:58:43 +00:00
|
|
|
cmd.Stdout = os.Stdout
|
|
|
|
cmd.Stderr = os.Stderr
|
|
|
|
err := cmd.Run()
|
2015-02-22 00:07:29 +00:00
|
|
|
if err != nil {
|
2015-08-20 14:42:33 +00:00
|
|
|
log.WithFields(log.Fields{"err": err, "user": user, "auth_key": authorizedKey}).Error("Error updating SSH authorized_keys")
|
2015-02-22 00:07:29 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|