Fixes the custom script to fetch the public key.

Change-Id: If25d854d66b8084ea3618770e50e90ccc93b46aa
Closes-Bug: #1253912
This commit is contained in:
Chandan kumar 2013-11-22 14:52:58 +05:30
parent 292c139288
commit 67cc68699d

View File

@ -244,10 +244,10 @@ fi
# Fetch public key using HTTP
ATTEMPTS=30
FAILED=0subl
FAILED=0
while [ ! -f /root/.ssh/authorized_keys ]; do
curl -f http://169.254.169.254/latest/meta-data/public-keys/0/openssh-key > /tmp/metadata-key 2>/dev/null
if [ \$? -eq 0 ]; then
if [ $? -eq 0 ]; then
cat /tmp/metadata-key >> /root/.ssh/authorized_keys
chmod 0600 /root/.ssh/authorized_keys
restorecon /root/.ssh/authorized_keys
@ -258,6 +258,15 @@ while [ ! -f /root/.ssh/authorized_keys ]; do
echo "*****************"
cat /root/.ssh/authorized_keys
echo "*****************"
else
FAILED=`expr $FAILED + 1`
if [ $FAILED -ge $ATTEMPTS ]; then
echo "Failed to retrieve public key from instance metadata after $FAILED attempts, quitting"
break
fi
echo "Could not retrieve public key from instance metadata (attempt #$FAILED/$ATTEMPTS), retrying in 5 seconds..."
sleep 5
fi
done</programlisting>
<note>
<para>Some VNC clients replace : (colon) with ; (semicolon) and _ (underscore) with