Where does SSH contextualization public key get copied?

Okay, another dumb question. I have a ssh key configured in the template contextualization, but what user is supposed to get it? Root? I don’t see it when I log in with my password. VM is CentOS.

TEMPLATE CONTENTS
CONTEXT=[
  NETWORK="YES",
  SSH_PUBLIC_KEY="ssh-rsa AAAAB3NzaC1yc2EAAAADAQA.. .. ..  shebop dewop",
  START_SCRIPT_BASE64="eXVtIC15IGluc3RhbGwgYW5zaWJsZQ==" ]

Also I have a start script, “yum -y install ansible” and it never seems to run. Why wouldn’t it work? I don’t see any errors in /var/log/messages when the VM boots. The network contextualization seems to work fine- it adds IP addr, gateway, nameserver, etc.

The context script doesn’t seem to get the value of the key I set when the VM boots:

[root@localhost one-context]# pwd
/var/run/one-context
[root@localhost one-context]# cat context.sh.local
# Context variables generated by OpenNebula
DISK_ID='2'
ETH0_CONTEXT_FORCE_IPV4=''
...
...
...
SSH_PUBLIC_KEY=''

Hello @christaylor

Yes, root is the user that you should use to log in.

Execute this command DEBUG=1 /usr/sbin/one-contextd all force inside the VM, maybe it helps you to debug the problem.

Could you please check if that value is in the VM xml? You can check it using onevm show <VM_ID> -x command.

Best,
Álex.

Thanks for your reply. If I run “bash -x /usr/sbin/one-contextd all force” I get this- the part of the script seems to return exit code 0:

+ for _script in '${_scripts}'
++ basename /etc/one-context.d/loc-22-ssh_public_key
+ local _name=loc-22-ssh_public_key
+ log debug 'Script loc-22-ssh_public_key: Starting ...'
+ local _echo_fd=
+ '[' -n '' ']'
+ '[' '' = 1 ']'
+ '[' '' = 2 ']'
+ systemd-cat -t one-contextd -p debug echo 'Script loc-22-ssh_public_key: Starting ...'
+ '[' 0 '!=' 0 ']'
+ return 0
++ /etc/one-context.d/loc-22-ssh_public_key force
+ _out=
+ local _rtn=0
+ '[' -n '' ']'
+ '[' 0 -eq 0 ']'
+ local _level=debug
+ log debug 'Script loc-22-ssh_public_key: Finished with exit code 0'
+ local _echo_fd=
+ '[' -n '' ']'
+ '[' '' = 1 ']'
+ '[' '' = 2 ']'
+ systemd-cat -t one-contextd -p debug echo 'Script loc-22-ssh_public_key: Finished with exit code 0'
+ '[' 0 '!=' 0 ']'
+ return 0

On my frontend “onevm show 34 -x” still doesn’t show a key:

<CONTEXT>
      <DISK_ID><![CDATA[2]]></DISK_ID>
      <ETH0_CONTEXT_FORCE_IPV4><![CDATA[]]></ETH0_CONTEXT_FORCE_IPV4>
      <ETH0_DNS><![CDATA[128.222.111.194]]></ETH0_DNS>
      <ETH0_EXTERNAL><![CDATA[]]></ETH0_EXTERNAL>
      <ETH0_GATEWAY><![CDATA[192.168.122.1]]></ETH0_GATEWAY>
      <ETH0_GATEWAY6><![CDATA[]]></ETH0_GATEWAY6>
      <ETH0_IP><![CDATA[192.168.122.10]]></ETH0_IP>
      <ETH0_IP6><![CDATA[]]></ETH0_IP6>
      <ETH0_IP6_PREFIX_LENGTH><![CDATA[]]></ETH0_IP6_PREFIX_LENGTH>
      <ETH0_IP6_ULA><![CDATA[]]></ETH0_IP6_ULA>
      <ETH0_MAC><![CDATA[02:00:c0:a8:7a:0a]]></ETH0_MAC>
      <ETH0_MASK><![CDATA[255.255.255.0]]></ETH0_MASK>
      <ETH0_MTU><![CDATA[]]></ETH0_MTU>
      <ETH0_NETWORK><![CDATA[192.168.122.0]]></ETH0_NETWORK>
      <ETH0_SEARCH_DOMAIN><![CDATA[]]></ETH0_SEARCH_DOMAIN>
      <ETH0_VLAN_ID><![CDATA[]]></ETH0_VLAN_ID>
      <ETH0_VROUTER_IP><![CDATA[]]></ETH0_VROUTER_IP>
      <ETH0_VROUTER_IP6><![CDATA[]]></ETH0_VROUTER_IP6>
      <ETH0_VROUTER_MANAGEMENT><![CDATA[]]></ETH0_VROUTER_MANAGEMENT>
      <NETWORK><![CDATA[YES]]></NETWORK>
      <SSH_PUBLIC_KEY><![CDATA[]]></SSH_PUBLIC_KEY>
      <TARGET><![CDATA[hda]]></TARGET>
    </CONTEXT>

If I go on the VM and mount /dev/sr0 I don’t see anything in the script either:

[root@localhost mnt]# cat context.sh
# Context variables generated by OpenNebula
DISK_ID='2'
ETH0_CONTEXT_FORCE_IPV4=''
ETH0_DNS='128.125.253.194'
ETH0_EXTERNAL=''
ETH0_GATEWAY='192.168.122.1'
ETH0_GATEWAY6=''
ETH0_IP='192.168.122.10'
ETH0_IP6=''
ETH0_IP6_PREFIX_LENGTH=''
ETH0_IP6_ULA=''
ETH0_MAC='02:00:c0:a8:7a:0a'
ETH0_MASK='255.255.255.0'
ETH0_MTU=''
ETH0_NETWORK='192.168.122.0'
ETH0_SEARCH_DOMAIN=''
ETH0_VLAN_ID=''
ETH0_VROUTER_IP=''
ETH0_VROUTER_IP6=''
ETH0_VROUTER_MANAGEMENT=''
NETWORK='YES'
SSH_PUBLIC_KEY=''
TARGET='hda'

I don’t see any mention of my start script either. Where’s that supposed to show up?

Thanks for your help.

Hello @christaylor

Did you set the SSH public key for the user? You can do it in Sunstone (user -> settings -> auth)

If you set there, it will be copied to all templates you instantiate. You can also add an specific key in the template if you want, just update the template and paste there your key.

Best,
Álex.

Thanks for the tip on setting the user auth settings. I got the key and start script context setting to work, it turns out I didn’t have the contextualization package installed, or I did in in the wrong order or something.