Commit graph

12 commits

Author SHA1 Message Date
Baptiste Daroussin
a6ecbf2b35 nuageinit: improve debugging when mkdir fails 2024-08-20 12:09:43 +02:00
Baptiste Daroussin
19fb9ad746 nuageinit: readd ssh key parsing when key is in meta_data.json
in openstack when no user is specified but a sshkey is provided
the information is stored in meta_data.json under "public_keys"

PR:	280461
Reported by:	tdb
2024-08-20 12:08:29 +02:00
Jose Luis Duran
8edd6c07c8 nuageinit: Fix tests
Commit 07d17ca189 set the recommended
permissions for the SSH authorized keys file and directory.  The tests,
however, were failing on CI.

Use stat to check for the proper permissions.

Fixes:	07d17ca189 nuageinit: Set recommended SSH permissions
Reported by:	Jenkins
2024-07-25 11:15:29 +02:00
Jose Luis Duran
7aecd689e3 nuageinit: Fix the homedir variable name
cloud-init uses homedir, not home.
2024-07-25 11:15:29 +02:00
Jose Luis Duran
07d17ca189 nuageinit: Set recommended SSH permissions
As stated in sshd(8), the recommended permissions for ~/.ssh are
read/write/execute for the user, and not accessible by others; and the
recommended permissions for ~/.ssh/authorized_keys are read/write for
the user, and not accessible by others.
2024-07-23 15:02:28 +02:00
Jose Luis Duran
7b73ecfe64 nuageinit: Accept plain text passwords
Per pw(8), when -H is set, the password should be supplied already
encrypted in a form suitable for writing directly to the password
database (passwd in cloud-init tems); -h provides a special interface by
which interactive scripts can set an account password using pw(8) in
plain text (plain_text_passwd in cloud-init terms).

The default user (freebsd) is defined with a plain_text_passwd
(freebsd), not with an encrypted one.
2024-07-23 15:01:54 +02:00
Baptiste Daroussin
cde6642431 nuageinit: check for both user_data and user-data
openstack, ec2 and other implementation of cloudinit disagrees on the
name of the file "user-data" or "user_data", test both and use the first
found

PR:	279876
2024-06-27 10:32:14 +02:00
Baptiste Daroussin
8d7331e62a nuageinit: fix authorized_key test
After miss reading the cloudinit spec I ended up writting a wrong
test for basic ssh key setup, nuageinit has been fixed, but not
the test, here is the actual fix.

Reported by:	markj
2024-06-05 11:00:54 +02:00
Baptiste Daroussin
fa07b02f6e nuageinit: make addsshkey friendly for testsuite 2024-06-05 11:00:53 +02:00
Baptiste Daroussin
83fcab792c nuageinit: use pw(8) instead of getent(1)
pw(8) allows to seek for users in a custom rootdir, which makes it
easier for a testsuite

MFC After:	3 days
2024-06-05 11:00:53 +02:00
Jeremy Collin
48edad2edf fix (nuageinit): SSH keys are not handled in metadata but in userdata
MFC After: 1 day
2024-05-21 16:52:42 +02:00
Baptiste Daroussin
a42d6f7601 nuageinit: add basic support for cloudinit.
this is a very early script to support cloudinit, it does not intend to
be a full featured cloudinit client, but will support a good enough
subset to be viable in most case.

It support nocloud and openstack config-2 config drive mode (iso9660 or
msdosfs)

The following features are currently supported:
- adding users (including a default user named 'freebsd' with password
  'freebsd'
- adding groups
- adding ssh keys
- static ipv4, static ipv6, dynamic ipv4

With this one is able to use the 'bring your own image feature" out of
box.

It is expected that the script grows the support of other clouds
supporting cloud-init, contributions are welcomed.

It is designed to be only run once via the firstboot mecanism.

Sponsored by:	OVHCloud
MFC After:	3 weeks
Differential Revision:	https://reviews.freebsd.org/D44141
2024-03-15 09:22:16 +01:00