packer-arch/srv/enable-ssh.sh
Nicolas Iooss 27fa924f05 Use openssl passwd -6 instead of -crypt
OpenSSL 3.0 removed option `-crypt`. Use `-6` as this option seems
unlikely to be removed soon.

While at it, quote shell variables in a safe way to prevent issues when
they contain space characters.

Fixes: https://github.com/elasticdog/packer-arch/issues/80
2025-10-03 15:49:14 +00:00

11 lines
485 B
Bash

#!/usr/bin/env bash
PASSWORD="$(/usr/bin/openssl passwd -6 'vagrant')"
# Vagrant-specific configuration
/usr/bin/useradd --password "${PASSWORD}" --comment 'Vagrant User' --create-home --user-group vagrant
echo -e 'vagrant\nvagrant' | /usr/bin/passwd vagrant
echo 'Defaults env_keep += "SSH_AUTH_SOCK"' > /etc/sudoers.d/10_vagrant
echo 'vagrant ALL=(ALL) NOPASSWD: ALL' >> /etc/sudoers.d/10_vagrant
/usr/bin/chmod 0440 /etc/sudoers.d/10_vagrant
/usr/bin/systemctl start sshd.service