Possible ? openstack instance VM connecting without keypair.pem file

asked 2016-04-28 21:14:53 -0500

choong gravatar image

After I create instance VM ( Ubuntu ) then, I do have to use pem file to connect that VM. I usually do this

$ ssh -i xxxxxxxx.pem ubuntu@xxx.xxx.xxx.xxx

Let say, multi user want to access to the instance VM, I have to give .pem file to others every time they want to connect. I frustrated doing this.

I want something easier way such as without using pem file, or open it as public ( and still can connect to that VM ) OR what we normally do

$ ssh ubuntu@xxx.xxx.xxx.xxx

then type password.


edit retag flag offensive close merge delete

2 answers

Sort by » oldest newest most voted

answered 2016-05-02 06:43:08 -0500

dbaxps gravatar image

updated 2016-05-02 06:43:50 -0500

You can hack qcow2 image before uploading it to glance as follows :-

Each user issues

boris@fedora23wks ~]$ ssh-keygen
[boris@fedora23wks ~]$ cd .ssh
[boris@fedora23wks .ssh]$ ls -l
total 12
-rw-------. 1 boris boris 1675 Apr 26 23:49 id_rsa
-rw-r--r--. 1 boris boris  399 Apr 26 23:49 id_rsa.pub
-rw-r--r--. 1 boris boris 2280 Apr 27 01:03 known_hosts
[boris@fedora23wks .ssh]$ cat id_rsa.pub
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCuoS/L0ESzNV0nKCsHDip0XjcWZ36dT0xyD75Lyb47Q77CL0v6UZCLbu1mwa4fD5NuxZl54EnE3jVO3GBsHQP7ALlsPMbDV/D+Q1n95ntno+4iq0r/8j20OMDTNcKvqVx8ITvTvw21O9PvG7kSoZmXgwXDRWxWrmHHn+ojruPvwvBf33ckGMyA+hjHyniDTl8F4SlIWoYRU+HsmEAOc3XacekC8j1arkWwc2QmoMCwd6+loY/A2vETLrjEKLGlJo9ZxNNoJ9NE/k9VMbze2CXKNOmcEjSv+NeJIDKbqKdAapf01Jwip4WiN0qGUUl9x8d0PAJ1+WdktTeCTfi3eAkr boris@fedora23wks

Say 10 users each one on his workstation created rsa private and public keys

# guestfish --rw -a xenial-server-cloudimg-amd64-disk1.img
   Welcome to guestfish, the guest filesystem shell for
    editing virtual machine filesystems and disk images.

    Type: 'help' for help on commands
          'man' to read the manual
          'quit' to quit the shell

><fs> run
     100% ⟦▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒⟧ --:--
><fs> mount /dev/sda1 /
><fs> ls  /etc/cloud/cloud.cfg.d
><fs> cp  /etc/cloud/cloud.cfg.d/05_logging.cfg  /etc/cloud/cloud.cfg.d/91_logging.cfg
><fs> edit  /etc/cloud/cloud.cfg.d/91_logging.cfg
><fs> cat  /etc/cloud/cloud.cfg.d/91_logging.cfg
  - name: ubuntu
    groups: sudo
    shell: /bin/bash
    sudo: ['ALL=(ALL) NOPASSWD:ALL']
      - ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCuoS/L0ESzNV0nKCsHDip0XjcWZ36dT0xyD75Lyb47Q77CL0v6UZCLbu1mwa4fD5NuxZl54EnE3jVO3GBsHQP7ALlsPMbDV/D+Q1n95ntno+4iq0r/8j20OMDTNcKvqVx8ITvTvw21O9PvG7kSoZmXgwXDRWxWrmHHn+ojruPvwvBf33ckGMyA+hjHyniDTl8F4SlIWoYRU+HsmEAOc3XacekC8j1arkWwc2QmoMCwd6+loY/A2vETLrjEKLGlJo9ZxNNoJ9NE/k9VMbze2CXKNOmcEjSv+NeJIDKbqKdAapf01Jwip4WiN0qGUUl9x8d0PAJ1+WdktTeCTfi3eAkr boris@fedora23wks
     - ssh-rsa  <== for second user
     -ssh-rsa <==  for third user
     . . . . . . . 
     -ssh-rsa  <== for 10-th user

Then you close guestfish and upload image to glance && create vm using this image
Each one of 10 users may login to VM like:-

 ssh ubuntu@floatingIP

If you need 11-th user , you add to ~ubuntu/.ssh/authorized_keys his rsa public key ( generated by ssh-keygen)

edit flag offensive delete link more

answered 2016-05-02 00:06:16 -0500

Carrot gravatar image

You can do that make your own VM image.

Simple way belows.

 eg. Ubuntu case

 sudo modprobe nbd max_part=8
 qemu-nbd -c /dev/nbd0 trusty-server-cloudimg-amd64-disk1.img
 mount /dev/nbd0p1 /mnt/
 chroot /mnt
 adduser <userid>
 umount /mnt/
 nbd-client -d /dev/nbd0

If you want to use ubuntu account, you should change cloud-init config

edit flag offensive delete link more

Get to know Ask OpenStack

Resources for moderators

Question Tools

1 follower


Asked: 2016-04-28 21:14:53 -0500

Seen: 1,161 times

Last updated: May 02 '16