added support to inject ssh key via guest_api
This commit is contained in:
parent
7e3d33093a
commit
b426f1ed51
@ -155,6 +155,7 @@ install_guest_api() {
|
|||||||
cd remote_decryption/guest_api
|
cd remote_decryption/guest_api
|
||||||
# TODO: stick to master branch after code stabilizes
|
# TODO: stick to master branch after code stabilizes
|
||||||
git checkout dtrfs
|
git checkout dtrfs
|
||||||
|
git pull
|
||||||
cargo build --release > "${my_location}/guest_api.log" 2>&1 ||
|
cargo build --release > "${my_location}/guest_api.log" 2>&1 ||
|
||||||
echo_red "Failed to build guest_api"
|
echo_red "Failed to build guest_api"
|
||||||
strip --discard-all target/release/guest_api
|
strip --discard-all target/release/guest_api
|
||||||
|
4
init.sh
4
init.sh
@ -4,6 +4,7 @@ source /init_functions.sh
|
|||||||
export INSTALL_URL="/tmp/detee_install_url"
|
export INSTALL_URL="/tmp/detee_install_url"
|
||||||
export INSTALL_SHA="/tmp/detee_install_sha"
|
export INSTALL_SHA="/tmp/detee_install_sha"
|
||||||
export ROOT_KEYFILE="/tmp/detee_root_keyfile"
|
export ROOT_KEYFILE="/tmp/detee_root_keyfile"
|
||||||
|
export SSH_KEY_FILE="/tmp/detee_ssh_key"
|
||||||
|
|
||||||
create_mounts
|
create_mounts
|
||||||
load_modules
|
load_modules
|
||||||
@ -18,7 +19,8 @@ else
|
|||||||
mount_root
|
mount_root
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# TODO: move ssh key to the guest API
|
# TODO: take into consideration to remove github key injection
|
||||||
github_ssh_key
|
github_ssh_key
|
||||||
|
detee_ssh_key
|
||||||
|
|
||||||
exec switch_root /mnt /sbin/init "$@"
|
exec switch_root /mnt /sbin/init "$@"
|
||||||
|
@ -63,6 +63,8 @@ setup_network() {
|
|||||||
ip link set eth0 up
|
ip link set eth0 up
|
||||||
ip route add default via $gateway
|
ip route add default via $gateway
|
||||||
echo nameserver $nameserver > /etc/resolv.conf
|
echo nameserver $nameserver > /etc/resolv.conf
|
||||||
|
sleep 4
|
||||||
|
ping -c 2 $gateway
|
||||||
}
|
}
|
||||||
|
|
||||||
install_os() {
|
install_os() {
|
||||||
@ -104,12 +106,24 @@ github_ssh_key() {
|
|||||||
cd /mnt/root/.ssh
|
cd /mnt/root/.ssh
|
||||||
touch authorized_keys
|
touch authorized_keys
|
||||||
key="$(wget -O - https://github.com/${github_user}.keys)"
|
key="$(wget -O - https://github.com/${github_user}.keys)"
|
||||||
grep -F "$( echo key | awk '{ print $2 }' )" authorized_keys || {
|
grep -F "$( echo $key | awk '{ print $2 }' )" authorized_keys || {
|
||||||
echo "$key" >> authorized_keys
|
echo "$key" >> authorized_keys
|
||||||
chmod 600 authorized_keys
|
chmod 600 authorized_keys
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# this can be injected through the guest_api
|
||||||
|
detee_ssh_key() {
|
||||||
|
local key=''
|
||||||
|
mkdir -p /mnt/root/.ssh
|
||||||
|
[[ -f "$SSH_KEY_FILE" ]] && while read -r key; do
|
||||||
|
grep -F "$( echo $key | awk '{ print $2 }' )" authorized_keys || {
|
||||||
|
echo "$key" >> authorized_keys
|
||||||
|
}
|
||||||
|
done < /tmp/detee_ssh_key
|
||||||
|
chmod 600 authorized_keys
|
||||||
|
}
|
||||||
|
|
||||||
mount_root() {
|
mount_root() {
|
||||||
cryptsetup open -d $ROOT_KEYFILE /dev/vda1 root
|
cryptsetup open -d $ROOT_KEYFILE /dev/vda1 root
|
||||||
mount /dev/mapper/root /mnt
|
mount /dev/mapper/root /mnt
|
||||||
|
Loading…
Reference in New Issue
Block a user