2016-10-31 09:23:33 +00:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
if [ ${DIB_DEBUG_TRACE:-0} -gt 0 ]; then
|
|
|
|
set -x
|
|
|
|
fi
|
|
|
|
set -eu
|
|
|
|
set -o pipefail
|
|
|
|
|
|
|
|
# Set cloud-init to allow password authentication
|
|
|
|
if [ -n "${DIB_CLOUD_INIT_ALLOW_SSH_PWAUTH:-}" ]; then
|
|
|
|
if [ -f "/etc/cloud/cloud.cfg" ]; then
|
2023-09-15 14:40:36 +00:00
|
|
|
if [ -z "$(grep ssh_pwauth /etc/cloud/cloud.cfg)" ]; then
|
2016-10-31 09:23:33 +00:00
|
|
|
echo "ssh_pwauth not exist. append to EOF"
|
2023-09-15 14:40:36 +00:00
|
|
|
echo "ssh_pwauth: 1" >> /etc/cloud/cloud.cfg
|
2016-10-31 09:23:33 +00:00
|
|
|
else
|
|
|
|
echo "ssh_pwauth exist. make sure ssh_pwauth enabled"
|
|
|
|
sed -i -e 's/ssh_pwauth: *0/ssh_pwauth: 1/g' /etc/cloud/cloud.cfg
|
|
|
|
sed -i -e 's/ssh_pwauth: *False/ssh_pwauth: True/g' /etc/cloud/cloud.cfg
|
|
|
|
sed -i -e 's/ssh_pwauth: *false/ssh_pwauth: true/g' /etc/cloud/cloud.cfg
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
fi
|