mirror of
https://github.com/apache/cloudstack.git
synced 2025-10-26 08:42:29 +01:00
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
40db230095
commit
7cf4c375c2
@ -520,6 +520,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
debian/cloud-setup.install
vendored
1
debian/cloud-setup.install
vendored
@ -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
|
||||
|
||||
49
setup/bindir/cloud-set-guest-sshkey.in
Executable file
49
setup/bindir/cloud-set-guest-sshkey.in
Executable file
@ -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…
x
Reference in New Issue
Block a user