aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSilvio Rhatto <rhatto@riseup.net>2017-03-14 10:14:08 -0300
committerSilvio Rhatto <rhatto@riseup.net>2017-03-14 10:14:08 -0300
commit123a756c8ea7cd103f28d8bf0751966a6ad19892 (patch)
tree1e955a14fd72166b26d9009c4072be7cd2f7078b
parent78056db240dadd1b8656d1cc541a1a4a2e45e518 (diff)
downloadutils-ssh-123a756c8ea7cd103f28d8bf0751966a6ad19892.tar.gz
utils-ssh-123a756c8ea7cd103f28d8bf0751966a6ad19892.tar.bz2
Add checks into ssh-privsend and ssh-authorized-send
-rwxr-xr-xssh-authorized-send14
-rwxr-xr-xssh-privsend14
2 files changed, 28 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"
diff --git a/ssh-privsend b/ssh-privsend
index 8767f57..3770898 100755
--- a/ssh-privsend
+++ b/ssh-privsend
@@ -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