cbsd / cbsd

Yet one more wrapper around jail, bhyve, QEMU and XEN
https://bsdstore.ru
BSD 2-Clause "Simplified" License
676 stars 76 forks source link

cloud-init code does not recognize ssh-ed25519 keys #626

Closed VVelox closed 3 years ago

VVelox commented 3 years ago

Mandatory info for bug reports:

FreeBSD version ( uname -a ): FreeBSD nibbles1.vvelox.net 12.2-STABLE FreeBSD 12.2-STABLE stable/12-n232902-2225c9780af vixen42 amd64

CBSD version ( cbsd version ): 13.0.15

[root@nibbles1]0|/storage/cbsd>cbsd bcreate jname=foo vm_os_type='freebsd'  vm_os_profile='cloud-FreeBSD-ufs-x64-13.0'  vm_ram='1g'  vm_cpus='1'  imgsize='10g'  ci_gw4='192.168.14.2'  ci_ip4_addr='192.168.14.155'  ci_user_pubkey='ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIOhVHrUkDDwsgSWGwm3f8rReFZ8m7awoVnM8McFMTVU4 kitsune@vixen42.vulpes.vvelox.net' 

Global VM ZFS guid: 5211205099147136051
To edit VM properties use: cbsd bconfig jname=foo
To start VM use: cbsd bstart foo
To stop VM use: cbsd bstop foo
To remove VM use: cbsd bremove foo
For attach VM console use: cbsd blogin foo

Creating foo complete: Enjoy!
auto-generate cloud-init settings: /storage/cbsd/jails-system/foo/cloud-init
cloudinit: invalid ssh key: [ssh-ed25519]. valid key: ssh-rsa,ssh-ed25519,ecdsa-*,ssh-dsa
cloudinit error
VVelox commented 3 years ago

Hmm... seems to be parsing it improperly and into three keys, intering along the spaces to the left.

[root@nibbles1]0|/storage/cbsd>rg ssh-ed25519 vm/foo/rc.conf_foo
32:ci_user_pubkey="ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIOhVHrUkDDwsgSWGwm3f8rReFZ8m7awoVnM8McFMTVU4 kitsune@vixen42.vulpes.vvelox.net"
33:ci_user_pubkey="ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIOhVHrUkDDwsgSWGwm3f8rReFZ8m7awoVnM8McFMTVU4"
34:ci_user_pubkey="ssh-ed25519"
[root@nibbles1]0|/storage/cbsd>
olevole commented 3 years ago

@VVelox can you check https://github.com/cbsd/cbsd/commit/1a6ff07bad1c99ae4f7fade2ef43d91fe232acbe (as work-around) ?

in subr/nc.subr:

-- [ ${_tofile} -eq 1 ] && printf "${ARG}=\"${VAL}\"\n" >> ${CBSD_INIT_SAVE2FILE}
++ [ ${_tofile} -eq 1 ] && ${SYSRC_CMD} -qf ${CBSD_INIT_SAVE2FILE} ${ARG}="${VAL}" > /dev/null 2>&1
olevole commented 3 years ago

the init() in CBSD is very difficult for shell due to the /bin/sh restriction. For a long time I wanted to rewrite this piece in C, but still not ;)

VVelox commented 3 years ago

Looks good!

And well if you don't mind Perl, that is a hell of a lot cleaner than shell and very robust. If there are any tasks that can be broken out in that area, I would be happy to help.

olevole commented 3 years ago

In most cases, the shell is a suitable tool for CBSD, because there are not very many libraries for components ( libzfs, libjail appeared after the cbsd ), but 'ifconfig', carp, hast, ipfw, pf, pkg - tons of external tools do not have necessary bindings.

So in any language most of the CBSD-like projects will look like: 'system("extcmd"), popen("extcmd", exec*("extcmd").'

I believe that at the moment the CBSD is at the end of its development and the project is nearing completion (this is not about the termination of support), so at the moment there are no plans to rewrite it in another language. Further development should go with higher-level abstractions ( DRS (host recomendation), controllers, monitoring, service-discovery, networking and other) - from my point of view, this is a further development of the project and they will require other programming languages. CBSD should remain as a framework for low-level operations only (e.g. attach disk/nic, restart jail ..).

I will be optimizing for bottlenecks soon ( init() function is one of them), but these will be spot improvements.

olevole commented 3 years ago

I will close PR if the problem is solved. Refactoring of init() in long-term/todo.