Commit 899b1946 authored by Thomas Goirand's avatar Thomas Goirand

Added an option to choose the login username, thanks to Jordan Pittier

<jordan.pittier@gmail.com> for providing the feature (Closes: #752787).
parent 91d78763
......@@ -14,6 +14,7 @@ Options are:
--image-size|-is <image-size> (default: 1G)
--automatic-resize|-ar
--automatic-resize-space|-ars <suplementary-space> (default: 50M)
--login|-l <userlogin> (default: debian)
--password|-p <root-password> (dangerous option: avoid it if possible)
For more info: man $0"
exit 1
......@@ -97,6 +98,15 @@ for i in $@ ; do
usage
fi
;;
"--login"|"-l")
if [ -z "${2}" ] ; then
echo "No parameter defining the user login"
usage
fi
USER_LOGIN=${2}
shift
shift
;;
"--password"|"-p")
if [ -z "${2}" ] ; then
echo "No parameter defining the root password"
......@@ -129,6 +139,9 @@ fi
if [ -z "${AUTOMATIC_RESIZE_SPACE}" ] ; then
AUTOMATIC_RESIZE_SPACE=50
fi
if [ -z "${USER_LOGIN}" ] ; then
USER_LOGIN=debian
fi
NEEDED_PACKAGES=sudo,adduser,locales,extlinux,openssh-server,linux-image-amd64,euca2ools,file,kbd
if [ "${RELEASE}" = "jessie" ] ; then
......@@ -216,8 +229,8 @@ fi
# is always the same.
sed -i "s/PermitRootLogin yes/PermitRootLogin without-password/" ${MOUNT_DIR}/etc/ssh/sshd_config
# Add a default "debian" user which is used by cloud-init by default
chroot ${MOUNT_DIR} adduser --gecos Debian-cloud-init-user --disabled-password --quiet debian
# Add a default user which is used by cloud-init by default
chroot ${MOUNT_DIR} adduser --gecos Cloud-init-user --disabled-password --quiet ${USER_LOGIN}
# Adds the "debian" user to sudoers, since that is the way
# cloud-init grant access
......@@ -326,6 +339,9 @@ datasource_list: [ Ec2 ]" >${MOUNT_DIR}/etc/cloud/cloud.cfg.d/90_dpkg.cfg
echo "mount_default_fields: [~, ~, 'auto', 'defaults,nofail', '0', '2']" >>${MOUNT_DIR}/etc/cloud/cloud.cfg
echo "manage_etc_hosts: true" >>${MOUNT_DIR}/etc/cloud/cloud.cfg
# Set the cloud init default user (required for the keypair to be put in the right home directory)
sed -i "s/name: debian/name: ${USER_LOGIN}/" ${MOUNT_DIR}/etc/cloud/cloud.cfg
# Setting-up initramfs
chroot ${MOUNT_DIR} update-initramfs -u
......
......@@ -19,11 +19,13 @@ during the boot process, cloud\-init will resize the root partition on the fly
recent kernel allow that for ext3).
Cloud\-init is setup to use an Ec2 metadata server, which is what OpenStack is
compatible with. A "debian" user will be used to receive the ssh key from the
user data blob. This user is setup without a password (eg: adduser
\-\-disabled\-password). Once logged as this "debian" user in your new virtual
machine, you can "sudo" to root from that user, without needing a password. The
root password is "password" by default, and ssh into the root user without
compatible with. A "debian" (configurable with the use of the
.B --login
option) user will be used to receive the ssh key from the user data blob.
This user is setup without a password (eg: adduser \-\-disabled\-password).
Once logged as this "debian" user in your new virtual machine, you can
"sudo" to root from that user, without needing a password. The root
password is "password" by default, and ssh into the root user without
using an ssh keypair is disabled by default (PermitRootLogin without-password
is set in /etc/ssh/sshd_config).
......@@ -114,6 +116,13 @@ to the minimum. If this option is ommited, then 50G is used. If
.B \-\-automatic-resize
isn't used, then it is useless to set this option, which will be ignored.
.LP
.B \-\-login|\-l
.I <user-login>
.IP
Change the login name (default to debian) for the user created by Cloud-Init.
.LP
.B \-\-password|\-p
.I <root-password>
......
openstack-debian-images (0.10) unstable; urgency=medium
* Added an option to choose the login username, thanks to Jordan Pittier
<jordan.pittier@gmail.com> for providing the feature (Closes: #752787).
-- Thomas Goirand <zigo@debian.org> Thu, 03 Jul 2014 17:19:46 +0800
openstack-debian-images (0.9) unstable; urgency=medium
* Adds manage_etc_hosts: true in /etc/cloud/cloud.cfg.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment