generated from kubernetes/kubernetes-template-project
-
Notifications
You must be signed in to change notification settings - Fork 392
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1607 from abhay-krishna/ssh-password-dynamic
Set SSH password dynamically during auto-install
- Loading branch information
Showing
59 changed files
with
237 additions
and
82 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
#!/usr/bin/env bash | ||
|
||
# Copyright 2024 The Kubernetes Authors. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
set -o errexit | ||
set -o nounset | ||
set -o pipefail | ||
|
||
PACKER_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/../packer" && pwd -P)" | ||
|
||
openssl_binary=openssl11 | ||
if ! command -v $openssl_binary >/dev/null 2>&1; then | ||
openssl_binary=openssl | ||
if ! command -v $openssl_binary >/dev/null 2>&1; then | ||
echo "openssl or openssl11 binary must be in \$PATH" 1>&2 | ||
exit 1 | ||
fi | ||
fi | ||
|
||
# Check if openssl version is atleast 1.1.1 to support SHA-512 algorithm | ||
current_openssl_version=$($openssl_binary version | grep -Po "\d.\d.\d" | head -n1) | ||
minimum_openssl_version="1.1.1" | ||
if ! [ "$(printf '%s\n' "$minimum_openssl_version" "$current_openssl_version" | sort -V | head -n1)" = "$minimum_openssl_version" ]; then | ||
echo "OpenSSL version must be atleast $minimum_openssl_version, current OpenSSL version is $current_openssl_version" 1>&2 | ||
exit 1 | ||
fi | ||
|
||
export SSH_PASSWORD=$(tr -dc A-Za-z0-9 </dev/urandom | head -c 16; echo) | ||
SALT=$(tr -dc A-Za-z0-9 </dev/urandom | head -c 16; echo) | ||
export ENCRYPTED_SSH_PASSWORD=$($openssl_binary passwd -6 -salt $SALT -stdin <<< $SSH_PASSWORD) | ||
|
||
for file in $(find $PACKER_DIR -type f -name "*.tmpl"); do | ||
if [ -f "${file%.*}" ]; then | ||
rm ${file%.*} | ||
fi | ||
sed -e "s|\$SSH_PASSWORD|$SSH_PASSWORD|g" -e "s|\$ENCRYPTED_SSH_PASSWORD|$ENCRYPTED_SSH_PASSWORD|g" $file | tee ${file%.*} | ||
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
packer.json | ||
user-data.tmpl |
9 changes: 9 additions & 0 deletions
9
images/capi/packer/nutanix/linux/cloud-init/rhel/8/user-data.tmpl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
#cloud-config | ||
users: | ||
- name: builder | ||
sudo: ['ALL=(ALL) NOPASSWD:ALL'] | ||
chpasswd: | ||
list: | | ||
builder:$SSH_PASSWORD | ||
expire: False | ||
ssh_pwauth: True |
9 changes: 9 additions & 0 deletions
9
images/capi/packer/nutanix/linux/cloud-init/rhel/9/user-data.tmpl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
#cloud-config | ||
users: | ||
- name: builder | ||
sudo: ['ALL=(ALL) NOPASSWD:ALL'] | ||
chpasswd: | ||
list: | | ||
builder:$SSH_PASSWORD | ||
expire: False | ||
ssh_pwauth: True |
9 changes: 9 additions & 0 deletions
9
images/capi/packer/nutanix/linux/cloud-init/rockylinux/8/user-data.tmpl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
#cloud-config | ||
users: | ||
- name: builder | ||
sudo: ['ALL=(ALL) NOPASSWD:ALL'] | ||
chpasswd: | ||
list: | | ||
builder:$SSH_PASSWORD | ||
expire: False | ||
ssh_pwauth: True |
9 changes: 9 additions & 0 deletions
9
images/capi/packer/nutanix/linux/cloud-init/rockylinux/9/user-data.tmpl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
#cloud-config | ||
users: | ||
- name: builder | ||
sudo: ['ALL=(ALL) NOPASSWD:ALL'] | ||
chpasswd: | ||
list: | | ||
builder:$SSH_PASSWORD | ||
expire: False | ||
ssh_pwauth: True |
10 changes: 10 additions & 0 deletions
10
images/capi/packer/nutanix/linux/cloud-init/ubuntu/20.04/user-data.tmpl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
#cloud-config | ||
users: | ||
- name: builder | ||
sudo: ['ALL=(ALL) NOPASSWD:ALL'] | ||
shell: /bin/bash | ||
chpasswd: | ||
list: | | ||
builder:$SSH_PASSWORD | ||
expire: False | ||
ssh_pwauth: True |
10 changes: 10 additions & 0 deletions
10
images/capi/packer/nutanix/linux/cloud-init/ubuntu/22.04/user-data.tmpl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
#cloud-config | ||
users: | ||
- name: builder | ||
sudo: ['ALL=(ALL) NOPASSWD:ALL'] | ||
shell: /bin/bash | ||
chpasswd: | ||
list: | | ||
builder:$SSH_PASSWORD | ||
expire: False | ||
ssh_pwauth: True |
10 changes: 10 additions & 0 deletions
10
images/capi/packer/nutanix/linux/cloud-init/ubuntu/24.04/user-data.tmpl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
#cloud-config | ||
users: | ||
- name: builder | ||
sudo: ['ALL=(ALL) NOPASSWD:ALL'] | ||
shell: /bin/bash | ||
chpasswd: | ||
list: | | ||
builder:$SSH_PASSWORD | ||
expire: False | ||
ssh_pwauth: True |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
packer-common.json | ||
ks.cfg | ||
ks.json | ||
preseed.cfg | ||
preseed-efi.cfg | ||
user-data |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.