Here is how to inject multiple ssh public keys into a VM
It is possible to create a OpenStack key pair file, containing multiple public keys.
It is NOT possible to import it with Horizon 'Import Key Pair' feature. Horizon will strip the EOL at the import, resulting in only 1 key.
You have to use the command line to import it in your project!
Create a file containing the multiple public keys
One public key per line.
Example: multiple-keys.pub
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDvSspAfazEYYq3pQps6ROKkyg/gp2KbqOxgLcdq/ywac3huHicF4ji9Hg9jChQRWbu8PgtVp35ciW75j7HQXDZqnY+OGQUiOiLBxNkt+SMjiRh3XFwTwPXAmlsnzoCmOQdebNfYDGvgvojBvPh69IVOngcji7r8jzd3/nCM6pajXWf2g4wdCWRveGpIuNkXZSfAKob7ubk0BBHDEXQ+MDMVNUpmv3w4YUXfrEiTqCHCYE3sN2xrxlRLwVll5ahhWNW+CgZuMwHeVXBD9I/drFiN7CQntTPHeR8iVjZ5/RakAI4JpimWKGq/mrTaF4pBEGWcZBUzWrVveVAypv0ueSD user1@example.ch
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQC17Mx5i02F+dt0C0nUfibc1LHL+YQ9xdAq061komsVfbCffhjN0f6AtX0R0dc6CAc/N0FDRJYI34o+U75GwhvNPB2k0u0kucqPMdNXAlg4MbE8zN/pOA47fbpqMMejOj+tM9GhuvQbLek0y+kH3CW9tcqjJ+tvh5Pxii9hmTGFTD5cewGyBUs/Y2XOBCB5Aj4B8ZI4O0cnKn78Oo3IR0kFRggIDWBnHzaC1cM6+x7+hW9a3CE0plGzPlsJrC3UcaG5neZaBihb44Q3N4zeH4+6SrtMbaHnzE7d8fgC0RezlCRFxCrK5dMIUOUUBd/DJ6/gnKhjLE3aAN+Blg7S94sZ user2@example.ch
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDZxj7PHMu/VM7QF/dxobAPLGCFRNAEafIH/UGfr9KvlUAE6o+ptUnDYIjYT/6XbGy2O6NfK4BrdVNKVCuIs6LIIl/4qFUVcYwNa7yswvALDlSTOZnvqKyuPzouk3XNZrvqq6XuriQVHyERx16bMl9w9RTZMfomzy2G8iQoUHNZfRVkrPY0zPJRarIT/Ed3XuOuK9bnZkFfbgY4fGLsltuU2EAKzsAZr/0Is0md36X+mZR1Qh0mWyRGekh00zDzn7RTrvQPKOcg793wpE+yAC9M1NHob16H8d6fJJ2f1hIBP1a49OWCJzjBWhn22hkdD7bIQRUpitidENktTcdNotvR user3@example.ch
Import the keypair
Import the multiple keys file:
source .openrc
openstack keypair create --public-key multiple-keys.pub multiple-keys
And check that the keys were correctly imported:
$ openstack keypair show --public-key multiple-keys
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDvSspAfazEYYq3pQps6ROKkyg/gp2KbqOxgLcdq/ywac3huHicF4ji9Hg9jChQRWbu8PgtVp35ciW75j7HQXDZqnY+OGQUiOiLBxNkt+SMjiRh3XFwTwPXAmlsnzoCmOQdebNfYDGvgvojBvPh69IVOngcji7r8jzd3/nCM6pajXWf2g4wdCWRveGpIuNkXZSfAKob7ubk0BBHDEXQ+MDMVNUpmv3w4YUXfrEiTqCHCYE3sN2xrxlRLwVll5ahhWNW+CgZuMwHeVXBD9I/drFiN7CQntTPHeR8iVjZ5/RakAI4JpimWKGq/mrTaF4pBEGWcZBUzWrVveVAypv0ueSD user1@example.ch
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQC17Mx5i02F+dt0C0nUfibc1LHL+YQ9xdAq061komsVfbCffhjN0f6AtX0R0dc6CAc/N0FDRJYI34o+U75GwhvNPB2k0u0kucqPMdNXAlg4MbE8zN/pOA47fbpqMMejOj+tM9GhuvQbLek0y+kH3CW9tcqjJ+tvh5Pxii9hmTGFTD5cewGyBUs/Y2XOBCB5Aj4B8ZI4O0cnKn78Oo3IR0kFRggIDWBnHzaC1cM6+x7+hW9a3CE0plGzPlsJrC3UcaG5neZaBihb44Q3N4zeH4+6SrtMbaHnzE7d8fgC0RezlCRFxCrK5dMIUOUUBd/DJ6/gnKhjLE3aAN+Blg7S94sZ user2@example.ch
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDZxj7PHMu/VM7QF/dxobAPLGCFRNAEafIH/UGfr9KvlUAE6o+ptUnDYIjYT/6XbGy2O6NfK4BrdVNKVCuIs6LIIl/4qFUVcYwNa7yswvALDlSTOZnvqKyuPzouk3XNZrvqq6XuriQVHyERx16bMl9w9RTZMfomzy2G8iQoUHNZfRVkrPY0zPJRarIT/Ed3XuOuK9bnZkFfbgY4fGLsltuU2EAKzsAZr/0Is0md36X+mZR1Qh0mWyRGekh00zDzn7RTrvQPKOcg793wpE+yAC9M1NHob16H8d6fJJ2f1hIBP1a49OWCJzjBWhn22hkdD7bIQRUpitidENktTcdNotvR user3@example.ch
Launch a new VM
Start a VM with the 'multiple-keys' key pair and check the console log.
Instance Console Log:
Cloud-init v. 0.7.5 running 'modules:final' at Tue, 26 Sep 2017 08:55:35 +0000. Up 52.90 seconds.
ci-info: ++++++++++++++Authorized keys from /home/ubuntu/.ssh/authorized_keys for user ubuntu++++++++++++++
ci-info: +---------+-------------------------------------------------+---------+--------------------------+
ci-info: | Keytype | Fingerprint (md5) | Options | Comment |
ci-info: +---------+-------------------------------------------------+---------+--------------------------+
ci-info: | ssh-rsa | b0:2c:de:86:d5:8f:f9:eb:66:12:c3:91:47:ec:44:76 | - | user1@example.ch |
ci-info: | ssh-rsa | ec:4b:27:c8:76:60:2e:d8:ae:00:1a:d0:5d:a1:72:c3 | - | user2@example.ch |
ci-info: | ssh-rsa | c2:17:75:8a:14:ed:42:07:b6:11:c4:ad:87:b8:ac:d0 | - | user3@example.ch |
ci-info: +---------+-------------------------------------------------+---------+--------------------------+