diff options
author | Alex Landau <alex.landau@xorcom.com> | 2008-12-14 14:47:43 +0000 |
---|---|---|
committer | Alex Landau <alex.landau@xorcom.com> | 2008-12-14 14:47:43 +0000 |
commit | 626edff649102539c65156f7191595957e711aec (patch) | |
tree | 3f8b86bba17c8954aae3535a760d309861172502 /rt-from-remote | |
parent | 80ccc8a0cff45fff33c2d90f1e9118ea80658d9c (diff) |
rapid-tunneling:
- Created server part RPM.
git-svn-id: svn+ssh://xorcom/home/svn/debs/components/rapid-tunneling@6470 283159da-0705-0410-b60c-f2062b4bb6ad
Diffstat (limited to 'rt-from-remote')
-rwxr-xr-x | rt-from-remote | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/rt-from-remote b/rt-from-remote new file mode 100755 index 0000000..89d6623 --- /dev/null +++ b/rt-from-remote @@ -0,0 +1,37 @@ +#!/bin/bash + +# from-remote: this script is executed by the remote ssh client as +# instructed in .ssh/authorized_keys. + +# /bin/bash: because of the usage of the non-posix 'exec -a' + +exec 2>>err + +log() +{ + echo `date` "$@" >> log +} + +bad() +{ + mv $file bad/ra-$$.tar.gz + log "Bad connection attempt. SSH_CONNECTION='$SSH_CONNECTION', file=bad/ra-$$.tar.gz" + exit 1 +} + +mkdir -p ra ra/old bad +file=ra/ra-$$.tar.gz +dd of=$file bs=100k count=1 2>/dev/null +tar tzf $file >/dev/null 2>&1 || bad +pubkey=`tar xzf $file -O origkey | ssh-keygen -y -f /proc/self/fd/0 | awk '$1 == "ssh-rsa" {print $2}'` +[ -z "$pubkey" ] && bad +comment=`grep "$pubkey" .ssh/authorized_keys | awk '{print $NF}'` +[ -z "$comment" ] && bad +mv -f ra/$comment-* ra/old 2>/dev/null +mv $file ra/$comment-$$.tar.gz +file=ra/$comment-$$.tar.gz +keyfile=ra/$comment-key +tar xzf $file -O key > $keyfile || bad +chmod 600 $keyfile +log "Connection from $comment. SSH_CONNECTION='$SSH_CONNECTION', file=$file" +exec -a sleep-$comment sleep 1d |