Ssh key install under ubuntu user

HI,

I’m trying to create an ubuntu 16.04 appliance just as I did with ubuntu 14.04 and so far I’m not having any luck. The ONE contextualization seems to be able to install the ssh key but not in /home/ubuntu/.ssh/authorized_keys but under the root user. The weird thing is that under 14.04 the key is correctly installed under the ubuntu user. Can anyone point me to some information on how to accomplish this under 16.04?

We are running version 4.14.2 from the official Opennebula repo’s on a Centos 7.2 server.

This is the contextualization template I’m using:

{ "CONTEXT" : {
"NETWORK" : "YES",
"USERNAME": "ubuntu",
"SSH_PUBLIC_KEY" : "$USER[SSH_PUBLIC_KEY]",
"START_SCRIPT" : "apt-get update && apt-get dist-upgrade -y"
},
"CPU" : "1",
"FEATURES" : {
"ACPI" : "yes",
"LOCALTIME" : "no"
},
"GRAPHICS" : {
"LISTEN" : "0.0.0.0",
"TYPE" : "vnc"
},
"NIC" : {
"NETWORK" : "xxx",
"NETWORK_UNAME" : "xxx"
},
"LOGO" : "images/logos/ubuntu.png",
"MEMORY" : "1024",
"OS" : {
"ARCH" : "x86_64"
},
"VCPU" : "1"
}

From within the VM this is what the context.sh script looks

# cat /mnt/context.sh 
# Context variables generated by OpenNebula
DISK_ID='1'
ETH0_DNS='8.8.8.8 8.8.4.4'
ETH0_GATEWAY='xxx.xxx.xxx.xxx'
ETH0_IP='xxx.xxx.xxx.xxx'
ETH0_MAC='04:00:91:64:3b:cb'
ETH0_MASK='255.255.252.0'
ETH0_NETWORK='xxx.xxx.xxx.xxx'
NETWORK='YES'
SSH_PUBLIC_KEY='ssh-rsa xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'
TARGET='hda'
USERNAME='ubuntu'

And to be sure that we have the ubuntu user:

root@packer-ub1604:/etc# cat /etc/passwd | grep ubuntu
ubuntu:x:1000:1000:Ubuntu User,,,:/home/ubuntu:/bin/bash
root@packer-ub1604:/etc# cat /etc/group | grep ubuntu
adm:x:4:syslog,ubuntu
cdrom:x:24:ubuntu
sudo:x:27:ubuntu
dip:x:30:ubuntu
plugdev:x:46:ubuntu
ubuntu:x:1000:
lpadmin:x:111:ubuntu
sambashare:x:112:ubuntu

Im not sure what could be the issue but knowing there are quite number of different from Ubuntu 14.04 and 16.04, i suggest you run the context script manually to find the issue. The scripts are located at /etc/context.d/

Hello, I test in on 16.04.1 Ubuntu now and it’s works. I look into context script and it relay only on

/etc/passwd - which looks correct

this command is used to get home dir

getent passwd "${USERNAME}" | awk -F':' '{print $6}'

so try to run it manually with ubuntu username.

thats all.

Hi Kristian,

Can you post you sshd_config as well? I’ll do a manual check on the user. Thanks for testing btw! Oh and what version of the contextualization package do you use? The version we have within this VM is

dpkg -l | grep openneb
ii  opennebula-context           4.14.0-1                        all          contextualization package

Hi, I do nothing with sshd config, so it is default os provided.

I use 5.0.2 from gtihub

So I bet that problem is with your old package :slight_smile:

1 Like

Hi Kristian,

thanks I’ll test with the 5.0.2 package, the version I use is the one that is available from the Ubuntu repo’s.

yup that fixed it, the 5.0.2 packages seems to work fine. Thanks for the advise Kristian.