mirror of https://github.com/apache/cloudstack.git
cloud-set-guest-sshkey script (used by sshKey pair feature, has to be installed on the vm template) is a part of our code base now
This commit is contained in:
parent
81968b2325
commit
ade8a8ddcc
|
|
@ -508,6 +508,7 @@ fi
|
|||
%attr(0755,root,root) %{_bindir}/%{name}-setup-databases
|
||||
%attr(0755,root,root) %{_bindir}/%{name}-migrate-databases
|
||||
%attr(0755,root,root) %{_bindir}/%{name}-set-guest-password
|
||||
%attr(0755,root,root) %{_bindir}/%{name}-set-guest-sshkey
|
||||
%dir %{_datadir}/%{name}/setup
|
||||
%{_datadir}/%{name}/setup/*.sql
|
||||
%{_datadir}/%{name}/setup/*.sh
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
/usr/bin/cloud-setup-databases
|
||||
/usr/bin/cloud-migrate-databases
|
||||
/usr/bin/cloud-set-guest-password
|
||||
/usr/bin/cloud-set-guest-sshkey
|
||||
/usr/share/cloud/setup/*.sql
|
||||
/usr/share/cloud/setup/*.sh
|
||||
/usr/share/cloud/setup/server-setup.xml
|
||||
|
|
|
|||
|
|
@ -0,0 +1,49 @@
|
|||
#!/bin/bash
|
||||
#
|
||||
# Init file for SSH Public Keys Download Client
|
||||
#
|
||||
# chkconfig: 345 98 02
|
||||
# description: SSH Public Keys Download Client
|
||||
|
||||
# Modify this line to specify the user (default is root)
|
||||
user=ubuntu
|
||||
|
||||
|
||||
# Get DomR Ip
|
||||
DOMR_IP=$(ip route | grep default | cut -d' ' -f3)
|
||||
|
||||
if [ ! -n "$DOMR_IP" ]
|
||||
then
|
||||
echo "DomR IP address not found. Exiting."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Get ssh public key
|
||||
homedir=$(grep ^$user /etc/passwd|awk -F ":" '{print $6}')
|
||||
sshdir=$homedir/.ssh
|
||||
authorized=$sshdir/authorized_keys
|
||||
publickey=$(wget -t 3 -T 20 -O - http://$DOMR_IP/latest/public-keys 2>/dev/null)
|
||||
|
||||
if [ $? -ne 0 ]
|
||||
then
|
||||
echo "Error receiving SSH public key. Exiting."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
||||
if [ ! -e $sshdir ]
|
||||
then
|
||||
mkdir $sshdir
|
||||
fi
|
||||
|
||||
if [ ! -e $authorized ]
|
||||
then
|
||||
touch $authorized
|
||||
fi
|
||||
|
||||
cat $authorized|grep -v "$publickey" > $authorized
|
||||
echo "$publickey" >> $authorized
|
||||
|
||||
|
||||
exit 0
|
||||
|
||||
Loading…
Reference in New Issue