--- a/setup/command.go Wed Sep 11 23:29:12 2019 -0500
+++ b/setup/command.go Thu Sep 12 00:14:32 2019 -0500
@@ -9,6 +9,8 @@
+ "golang.org/x/crypto/ssh" "bitbucket.org/rw_grim/hgkeeper/globals"
"bitbucket.org/rw_grim/hgkeeper/hg"
@@ -153,7 +155,28 @@
+func isPubkey(filename string) error { + bytes, err := ioutil.ReadFile(filename) + if _, err := ssh.ParsePublicKey(bytes); err != nil { func (c *Command) Run(g *globals.Globals) error {
+ // make sure the adminPubkey is an SSH pubkey as it is too easy to + // accidentally give the path to the private key rather than the public + // key, and we do no want the private key in the repository. + if err := isPubkey(c.AdminSSHPubkey); err != nil { + return fmt.Errorf("%s is not a public key file", c.AdminSSHPubkey) + // create the admin repo if err := c.createAdminRepo(g.ReposPath, g.AdminRepo); err != nil {