X-Git-Url: https://review.fuel-infra.org/gitweb?a=blobdiff_plain;f=cirros-testvm%2Fsrc-cirros%2Fsrc%2Fusr%2Fbin%2Fssh-import-id;fp=cirros-testvm%2Fsrc-cirros%2Fsrc%2Fusr%2Fbin%2Fssh-import-id;h=279b86f5c779a6bca6b02fb1d59b775210427c62;hb=b0a0f15dfaa205161a7fcb20cf1b8cd4948c2ef3;hp=0000000000000000000000000000000000000000;hpb=c6ac3cd55ee2da956195eee393b0882105dfad4e;p=packages%2Ftrusty%2Fcirros-testvm.git diff --git a/cirros-testvm/src-cirros/src/usr/bin/ssh-import-id b/cirros-testvm/src-cirros/src/usr/bin/ssh-import-id new file mode 100755 index 0000000..279b86f --- /dev/null +++ b/cirros-testvm/src-cirros/src/usr/bin/ssh-import-id @@ -0,0 +1,31 @@ +#!/bin/sh + +burl="https://launchpad.net/~%s/+sshkeys" + +Usage() { + cat <&2; exit 1; } +[ "$1" = "-h" -o "$1" == "--help" ] && { Usage; exit 0; } +cd +umask 066 +fail() { echo "$@" 1>&2; exit 1; } +mkdir -m 755 -p .ssh || { fail "failed to make .ssh dir" 1>&2; exit 1; } + +for u in "$@"; do + url=$(printf "$burl" "$u") && + out=$(curl --silent - "$url") || + fail "failed to get key for $u [$url]" 1>&2 + # some keys come back with dos line end + out=$(echo "$out" | sed -e '/^$/d' -e '/^\r/d' \ + -e ':join /=[ ]/!{ N; s/[\n\r]//g ; b join }' \ + -e 's/[^a-zA-Z0-9@: .\/=+-]//g') + printf "%s\n" "$out" >> ".ssh/authorized_keys" || + fail "failed to write to .ssh/authorized_keys" + echo "Successfully authorized [$u]" +done + +# vi: ts=4 noexpandtab