aboutsummaryrefslogtreecommitdiff
path: root/ssh-authorized-send
diff options
context:
space:
mode:
Diffstat (limited to 'ssh-authorized-send')
-rwxr-xr-xssh-authorized-send14
1 files changed, 14 insertions, 0 deletions
diff --git a/ssh-authorized-send b/ssh-authorized-send
index c743812..ac687ff 100755
--- a/ssh-authorized-send
+++ b/ssh-authorized-send
@@ -3,9 +3,23 @@
# Send both public and private keys to a server.
#
+# Parameters
+BASENAME="`basename $0`"
KEY="$1"
SERVER="$2"
DESTKEY="~/.ssh/`basename $KEY`"
+# Checks
+if [ -z "$KEY" ]; then
+ echo "usage: $BASENAME <public-key-file>"
+ exit 1
+elif [ ! -e "$KEY" ]; then
+ echo "$BASENAME: file not found: $KEY"
+ exit 1
+elif grep -q -i private $KEY; then
+ echo "$BASENAME: please do not send a private key!"
+ exit 1
+fi
+
# Put on authorized_keys
cat $KEY | ssh $SERVER "mkdir -p ~/.ssh && chmod 700 ~/.ssh && touch ~/.ssh/authorized_keys && chmod 600 ~/.ssh/authorized_keys && cat >> ~/.ssh/authorized_keys"