|
@@ -16,10 +16,10 @@ PUBKEY="$( cat "${KEY_DIR}/${KEY_NAME}.pub" )"
|
|
|
|
|
|
# check if KEY_NAME exists into OVH User Account /me
|
|
# check if KEY_NAME exists into OVH User Account /me
|
|
# remote_keyname = "string or empty"
|
|
# remote_keyname = "string or empty"
|
|
-remote_keyname=$( ./ovhcli get "me/sshKey" | jq --arg v "${KEY_NAME}" -r '.|to_entries[]|select(.value == $v ).value' )
|
|
|
|
|
|
+remote_keyname=$( ovhcli get "me/sshKey" | jq --arg v "${KEY_NAME}" -r '.|to_entries[]|select(.value == $v ).value' )
|
|
|
|
|
|
# if remote_keyname exists check if pubkey is matching.
|
|
# if remote_keyname exists check if pubkey is matching.
|
|
-remote_pubkey=$( ./ovhcli get "me/sshKey/${KEY_NAME}" | jq -r '.key' )
|
|
|
|
|
|
+remote_pubkey=$( ovhcli get "me/sshKey/${KEY_NAME}" | jq -r '.key' )
|
|
|
|
|
|
# if remote_keyname does not match KEY_NAME = this KEY_NAME is not already uploaded into OVH Account
|
|
# if remote_keyname does not match KEY_NAME = this KEY_NAME is not already uploaded into OVH Account
|
|
if [ -z "${remote_keyname}" ] || [ "${remote_pubkey}" != "${PUBKEY}" ] ; then
|
|
if [ -z "${remote_keyname}" ] || [ "${remote_pubkey}" != "${PUBKEY}" ] ; then
|
|
@@ -27,7 +27,7 @@ if [ -z "${remote_keyname}" ] || [ "${remote_pubkey}" != "${PUBKEY}" ] ; then
|
|
echo ">>> Uploading ${KEY_DIR}/${KEY_NAME} to OVH account"
|
|
echo ">>> Uploading ${KEY_DIR}/${KEY_NAME} to OVH account"
|
|
HTTP_PAYLOAD='{ "key": "'${PUBKEY}'", "keyName": "'${KEY_NAME}'" }'
|
|
HTTP_PAYLOAD='{ "key": "'${PUBKEY}'", "keyName": "'${KEY_NAME}'" }'
|
|
|
|
|
|
- ./ovhcli post "me/sshKey" "${HTTP_PAYLOAD}" | jq -r 'select(. != null)'
|
|
|
|
|
|
+ ovhcli post "me/sshKey" "${HTTP_PAYLOAD}" | jq -r 'select(. != null)'
|
|
|
|
|
|
else
|
|
else
|
|
echo "SSH Keys are up-to-date"
|
|
echo "SSH Keys are up-to-date"
|