diff -ru gosc-scripts/imc-shell/imgcust-scripts/ConfigFile.sh gosc-scripts-modify/imc-shell/imgcust-scripts/ConfigFile.sh
--- gosc-scripts/imc-shell/imgcust-scripts/ConfigFile.sh 2015-09-15 11:21:08.091673000 -0700
+++ gosc-scripts-modify/imc-shell/imgcust-scripts/ConfigFile.sh 2015-09-15 15:02:07.123327547 -0700
@@ -851,6 +851,46 @@
echo "$val"
}
+# Retrieves rsa public key count.
+#
+# Args:
+# None
+# Results:
+# integer: count
+# Throws:
+# Dies in case setting is not present.
+ConfigFile_GetSshKeysCnt()
+{
+ local val='' # has to be declared before assigned
+
+ val=$(ConfigFile_GetOptionalNonEmptyString "SSH|KEYS") || exit 1
+
+ local myresult=0
+
+ if [[ -n "$val" ]]; then
+ local spl=(${val//,/ })
+ myresult="${#spl[@]}"
+ fi
+
+ echo "$myresult"
+}
+
+
+# Retrieves remote user ssh-rsa public key for password less login as root.
+#
+# Args:
+# None
+# Results:
+# string: ssh rsa public key
+# Throws:
+# Nothing
+ConfigFile_GetAdminSSHPubKey()
+{
+ local key_no=$1
+ local query="${key_no}|VALUE"
+ echo "$(ConfigFile_GetOptionalString $query)"
+}
+
# Retrieves whether to reset root password.
#
# Args:
diff -ru gosc-scripts/imc-shell/imgcust-scripts/CustomizationUtils.sh gosc-scripts-modify/imc-shell/imgcust-scripts/CustomizationUtils.sh
--- gosc-scripts/imc-shell/imgcust-scripts/CustomizationUtils.sh 2015-09-15 11:21:08.091673000 -0700
+++ gosc-scripts-modify/imc-shell/imgcust-scripts/CustomizationUtils.sh 2015-09-15 15:05:50.266659696 -0700
@@ -840,6 +840,7 @@
local resultVar=$1
local addrShowVar=$2
local tmpOvfEnvFile=$3
+ local sshKey=''
local formatResult= # unique name
@@ -853,24 +854,6 @@
EOF
)
-# securitySshRsa=$(GetOvfPropertyValue 'security.ssh-rsa' $tmpOvfEnvFile)
- securitySshRsa=''
-
- if [[ -n "$securitySshRsa" ]]; then
- if [[ "$securitySshRsa" != *ssh-rsa* ]]; then
- Debug "Appending 'ssh-rsa ' to the public key"
- securitySshRsa="ssh-rsa $securitySshRsa"
- fi
-
- export formatResult=$formatResult$(${CAT} <<EOF
-
-
-ssh_authorized_keys:
- - $securitySshRsa
-EOF
-)
- fi
-
local adminPwd=$(ConfigFile_GetAdminPassword)
if [[ -n "$adminPwd" ]]; then
@@ -888,6 +871,33 @@
)
fi
+ local ssh_key_cnt=$(ConfigFile_GetSshKeysCnt)
+ if [ "$ssh_key_cnt" -gt 0 ]; then
+ if [[ -z "$adminPwd" ]]; then
+ export formatResult=$formatResult$(${CAT} <<EOF
+
+users:
+ - name: root
+EOF
+)
+ fi
+ export formatResult=$formatResult$(${CAT} <<EOF
+
+ ssh_authorized_keys:
+EOF
+)
+ for k in $(seq 1 $ssh_key_cnt); do
+ Debug "Writing RSA SSH public key '$k'"
+ local key="KEY"
+ local key_query=$key$k
+ local sshKey=$(ConfigFile_GetAdminSSHPubKey $key_query)
+ export formatResult=$formatResult$(${CAT} <<EOF
+
+ - $sshKey
+EOF
+)
+ done
+ fi
export formatResult=$formatResult$(${CAT} <<EOF
write_files: