File: 21-cloud-init-allow-password-auth

package info (click to toggle)
python-diskimage-builder 3.39.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 5,704 kB
  • sloc: sh: 7,474; python: 6,454; makefile: 37
file content (22 lines) | stat: -rwxr-xr-x 767 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#!/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
        if [ -z "$(grep ssh_pwauth /etc/cloud/cloud.cfg)" ]; then
            echo "ssh_pwauth not exist. append to EOF"
            echo "ssh_pwauth: 1" >> /etc/cloud/cloud.cfg
        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