]> gitweb.fluxo.info Git - utils-ssh.git/commitdiff
Add checks into ssh-privsend and ssh-authorized-send
authorSilvio Rhatto <rhatto@riseup.net>
Tue, 14 Mar 2017 13:14:08 +0000 (10:14 -0300)
committerSilvio Rhatto <rhatto@riseup.net>
Tue, 14 Mar 2017 13:14:08 +0000 (10:14 -0300)
ssh-authorized-send
ssh-privsend

index c743812077536924a59d53f3820fa3ca8922bd4c..ac687ff4efc17c747aa69282932cfd4a9750d8e2 100755 (executable)
@@ -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"
index 8767f5719155c7e0da3340129a57dac261da215f..3770898b6fe00ce9531404f586e59801b9599cf4 100755 (executable)
@@ -3,10 +3,24 @@
 # 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 <private-key-file>"
+  exit 1
+elif [ ! -e "$KEY" ]; then
+  echo "$BASENAME: file not found: $KEY"
+  exit 1
+elif [ ! -e "$KEY.pub" ]; then
+  echo "$BASENAME: file not found: $KEY.pub"
+  exit 1
+fi
+
 # Put on authorized_keys
 #ssh-authorized-send $KEY.pub