#!/bin/sh
# scp: interactive Secure-Copy, via tar+ssh 
# (C) by M. Andreoli 1999


if [ -z "`which ssh`" ]; then
	echo "Sorry: can't found ssh."
	exit
fi

cat <<END

	scp act like UNIX "cp -a" (a *recursive* copy)
	LOCAL_SOURCE can be a list of files or local directory.
	scp will tar them and sent the result to REMOTE_USER at
	REMOTE_HOST, using a secure channel.

END


read -p "Enter LOCAL_SOURCE: " local_source
read -p "Enter REMOTE_HOST: "  remote_host

ru=root
read -p "Enter REMOTE_USER [$ru]: "  remote_user
[ -z "$remote_user" ] && remote_user=$ru

rd=/home/$remote_user
read -p "Enter REMOTE_DIR [$rd]: "  remote_dir
[ -z "$remote_dir" ] && remote_dir=$rd

set -x
tar -cf- $local_source| \
ssh -C -l $remote_user $remote_host "(cd $remote_dir; tar -xvf-)"
