1

I need to generate vagrant images that are configured as master/slave types. The slaves need to have SSH access to the master node, and there will be tens of thousands of slave instances.

Vagrant supplies Puppet and Chef provisioners, so I used Puppet since it is already floating around in the infrastructure so it should be easier to maintain here.

I am performing the following to generate SSH keys on the node that spawns the instances that will become my images like so:

ssh-keygen -t rsa -N "" -f keys/id_rsa_medusa

Unfortunately this seems to be generating SSH keys that still require a password. I am also generating these keys on an Ubuntu host and using puppet to pull them in to the vagrant instances, which does not seem to work.

What is a 1 liner or script I can use that will actually generate an ssh key with an empty passphrase?

Note:

This doesnt work,

echo -e '\n \n' | ssh-keygen -t rsa -f keys/id_rsa_medusa

BONUS:

ssh-keygen is creating keys with the base host's identity. Generally you would generate these from the host you are trying to ssh from and ssh-copy-id them over to the host you are trying to connect to. In this scenario, the host ID of the machine generating the keys is neither host. How do you generate generic keys that allow any host to access the server host?

Since this is vagrant (headless puppet) I am unable to copy keys between instances because somehow they both have the same IP address when I log into them. I have attempted to generate keys on the base host, then use the following to convert to PEM format, but it doesnt work either:

ssh-keygen -f keys/id_rsa_medusa -e -m pem > keys/id_rsa_medusa.pem

Thanks.

4

This works for me:

ssh-keygen -t rsa -N '' -f foo.rsa

Change the filename to what you wish. Note the use of ' instead of "

Not sure what you mean by the second bit...Isn't the generated key already PEM?

$ ssh-keygen -t rsa -N '' -f foo.rsa
Generating public/private rsa key pair.
Your identification has been saved in foo.rsa.
Your public key has been saved in foo.rsa.pub.
The key fingerprint is:
56:45:5d:54:a6:11:86:63:20:c9:b7:f3:b8:ba:c0:11 ssta@debianscratch
The key's randomart image is:
+---[RSA 2048]----+
|       ....ooo++*|
|        o...+..+ |
|      E  ..o ..  |
|       . .o      |
|      . S  +     |
|     . o  . .    |
|      o    .     |
|       .  .      |
|        oo       |
+-----------------+
$ file foo.rsa
foo.rsa: PEM RSA private key
$ cat foo.rsa
-----BEGIN RSA PRIVATE KEY-----
MIIEpAIBAAKCAQEA1xfyJbRRB1DOQpHFzzxR6s9z2iPX1U2q0WSbs/G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usyndZP3Jd/INMde0Kp+ix/6L4mY6jtGH
vhDF2Wwn81rmPAwy6xSPHLd0qqk9xAKmM0qRlb44kQLFALcKP12kUPmoy1dg2tyC
hDKPXK8eKxVYZXlRLadK6o8CgYBN8wZ0g5cGjUjkOmEKbwI3kfsBIwcr6RU3h4LG
Q3/AyzMtZi/2v1PGH3LYwqKpETi6P7V7npIcnlW5D9UJDwfVI8y8jwd7XyIQdoUx
OXltbl/P0ShfmpsGus2Iyr1jHqyV1t+vq8Szlw7KxFpCbA6Ktb8DAo8i5j6ATKRE
guiEbQKBgQDPRmBq4i2/X7C4gNSPI2DeSJMieQZpvbeUV2L0oKZxWWqC08plvyJQ
aUrdKPF9MEMK0B4PBq0A6IMAs+BRBjAiP6dNxmBkIK3ZxNuX9Hqswy7gQ+cIppcn
cA7sKLeSlI0bmJDQ6UQEJqDiL1ZoXyLaE/ckwgneR2U+VIfCpuKDKw==
-----END RSA PRIVATE KEY-----
| improve this answer | |
  • Created the key using: ssh-keygen -t rsa -N '' -f /root/.ssh/id_rsa_medusa on the server host. Copied the id_rsa private key to ~/.ssh/id_rsa_medusa.pem on the client host. Powered off both VMs. Converted the VM disk images to QCOW2, uploaded to Glance, and spawned server and client instances. 'ssh -i' as root from client to server using the pem file asks for a password. " Warning: Permanently added '10.207.255.213' (ECDSA) to the list of known hosts. Enter passphrase for key '/root/.ssh/id_rsa_medusa.pem': root@10.207.255.213's password: " – spyderdyne Nov 9 '15 at 21:12
  • This issue prevents me from automating my workflow. I am unable to complete my project until this is resolved. – spyderdyne Nov 10 '15 at 17:15
  • Try using -P '' instead of -N '' (the manpage is a little confusing, but it could be read that -P is for setting the initial password OR specifying the old one). Worth a shot anyway... – ssta Nov 10 '15 at 17:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.