From 8fa9d4540df65eec3963ecd8a2f90347384a6de7 Mon Sep 17 00:00:00 2001 From: Tzafrir Cohen Date: Wed, 15 Feb 2012 14:08:17 +0000 Subject: rtadm: integrate "upload" 'upload' is now a subcommand of rtadm git-svn-id: svn+ssh://xorcom/home/svn/debs/components/rapid-tunneling@10398 283159da-0705-0410-b60c-f2062b4bb6ad --- README | 6 ++++++ rt_handle_uploaded_key | 3 ++- rtadm | 20 ++++++++++++++++++++ rtadm.bash_completion | 4 ++-- 4 files changed, 30 insertions(+), 3 deletions(-) diff --git a/README b/README index 62c0a61..6c4a7fd 100644 --- a/README +++ b/README @@ -116,6 +116,8 @@ TODO: document it. For starters, its help message: # enable/disable future connections disconnect # disconnect connection + upload + # upload a copy of the key delete # disconnect, disable and delete any trace of the connection @@ -123,6 +125,10 @@ TODO: document it. For starters, its help message: Disabling it does not Disconnect an existing connection. It essentially rems-out the respective line in .ssh/authorized_keys . +"Upload" pipes the tarball over SSH to a remote system. Using the example +script rt_handle_uploaded_key on that remote system you can use it to +provide a download version of your keys. + Server Troubleshooting ~~~~~~~~~~~~~~~~~~~~~~ diff --git a/rt_handle_uploaded_key b/rt_handle_uploaded_key index 1ead82d..99b89c1 100755 --- a/rt_handle_uploaded_key +++ b/rt_handle_uploaded_key @@ -66,7 +66,8 @@ put_tarball() { rm "$tar_full" fi name=`tar_name "$tar_full"` - echo "$name: $tar_url" + port=`tar_port "$tar_full"` + echo "$port, $name: $tar_url" } list() { diff --git a/rtadm b/rtadm index dd16cb7..e161e48 100755 --- a/rtadm +++ b/rtadm @@ -2,6 +2,7 @@ USERNAME=support FROM_REMOTE_COMMAND=/usr/share/rapid-tunneling/bin/rt-from-remote +UPLOAD_TARGET="xorcom@updates.xorcom.com" CFG_FILE=/etc/rapid-tunneling/rtadm @@ -70,6 +71,18 @@ disable() sed -i "s|.*ra-[0-9]\+-$comment-[0-9]\+\$|#DISABLED#&|" ~/.ssh/authorized_keys } +upload() +{ + comment="$1" + tarball="$HOME/tar/remote-access-$comment.tar.gz" + if [ ! -r "$tarball" ]; then + echo >&2 "Tarball for $comment ($tarball) missing. Not uploading." + exit 1 + fi + cat "$tarball" | ssh -T $UPLOAD_TARGET \ + | tee -a "$HOME/upload.log" +} + delete() { comment="$1" @@ -123,6 +136,8 @@ usage() echo " # enable/disable future connections" echo " disconnect " echo " # disconnect connection" + echo " upload " + echo " # upload a copy of the key" echo " delete " echo " # disconnect, disable and delete any trace of the connection" exit 1 @@ -159,6 +174,11 @@ case "$1" in [ -z "$1" -o -n "$2" ] && usage disconnect "$1" ;; + upload) + shift + [ -z "$1" -o -n "$2" ] && usage + upload "$1" + ;; delete) shift [ -z "$1" -o -n "$2" ] && usage diff --git a/rtadm.bash_completion b/rtadm.bash_completion index 15e3c70..4f6c296 100644 --- a/rtadm.bash_completion +++ b/rtadm.bash_completion @@ -18,7 +18,7 @@ _rtadm() { COMPREPLY=() cur=`_get_cword` - commands='create show enable disable disconnect delete' + commands='create show enable disable disconnect upload delete' if [[ $COMP_CWORD -eq 1 ]] ; then COMPREPLY=( $( compgen -W "$commands" -- $cur ) ) @@ -42,7 +42,7 @@ _rtadm() { hosts=`_rtadm_ra_hosts_enabled` COMPREPLY=( $( compgen -W "$hosts" -- $cur ) ) ;; - delete) + delete|upload) hosts=`_rtadm_ra_hosts` COMPREPLY=( $( compgen -W "$hosts" -- $cur ) ) ;; -- cgit v1.2.3