Using SSH instead of SCP

Using the program SCP is not needed, use this scipt to use SSH for transferring files:

$ ssh user@machine "cat /remote/file" > /local/file

To use this trick in a shell script-wrapper:

$ cat
#!/bin/sh -x

host=$(echo "$1" | cut -d@ -f2 | cut -d: -f1)
user=$(echo "$1" | cut -d@ -f1)
remotefile=$(echo "$1" | cut -d: -f2)

if [ ! "$host" -o ! "$user" -o ! "$remotefile" -o ! "$localfile ] ; then
echo "Please use all requires options, for example:"
echo "$0 user@host:./file ."
exit 1

ssh $host "cat $remotefile" > $localfile
$ chmod 755

Now "replace" the normal SCP by using an alias:

$ alias scp="~/"

One flaw of this script is that all options will have to be configured statically in .ssh/config.

About Consultancy Articles Contact

References Red Hat Certified Architect By Robert de Bock Robert de Bock
Curriculum Vitae By Fred Clausen +31 6 14 39 58 72
By Nelson Manning