-# see that rdiff-backup has the same version as here
-debug "su $sourceuser -c \"ssh $desthost -l $destuser '$RDIFFBACKUP -V'\""
-if [ ! $test ]; then
- remoteversion=`su $sourceuser -c "ssh $desthost -l $destuser '$RDIFFBACKUP -V'" 2>&1`
+[ "$destdir" != "" ] || fatal "Destination directory not set"
+
+if [ "$desttype" == "remote" ]; then
+ # see if we can login
+ if [ "$testconnect" == "yes" ]; then
+ hostalive=0
+ debug "ssh -o PasswordAuthentication=no $desthost -l $destuser 'echo -n 1'"
+ ret=`ssh -o PasswordAuthentication=no $desthost -l $destuser 'echo -n host is alive'`
+ if echo $ret | grep "host is alive"; then
+ debug "Connected to $desthost as $destuser successfully"
+ else
+ fatal "Can't connect to $desthost as $destuser."
+ fi
+ fi
+ # see that rdiff-backup has the same version as here
+ debug "ssh $desthost -l $destuser '$RDIFFBACKUP -V'\""
+ remoteversion=`ssh $desthost -l $destuser "$RDIFFBACKUP -V | grep rdiff-backup"`