Re: remote copy file



Günther Schwarz wrote:

Ron Eggler wrote:

Günther Schwarz wrote:

Ron Eggler wrote:

Nikos Chantziaras wrote:

Nikos Chantziaras wrote:
[...]
As I understand it, you need the embedded device to initiate the
ransfer, not the remote PC

Err, the other way around. I meant "you need the remote PC to
initiate the transfer, not the embedded device."
I'm not sure if you understood my problem right. I have an embedded
device FROM which I need to send a file up to our central server.
rsync sounds good been looking into configuring it.
I put rsyncd on my "server" and it looks like:

You do not need rsyncd running on the embedded device, sshd is
enough. Just put a valid public key of an appropriate user on the
little box and use rsync on the server.
I do this every day as a crontab entry in order to copy backup files
on an Asus WL-HDD NAS called stupidlittlebox:
amanda@noname> rsync -av /Backup/amanda --rsh=ssh
stupidlittlebox:/tmp/harddisk/Backup/

nope i think you misunderstood me.

I did not misunderstand you. I just proposed you to initiate the process
from the server which will be simpler and more easy. If this is not an
option and if rsync does not work on the box you will have to use
another protocol like smtp, smp, ftp, or tftp. Be aware that on some of
these boxes almost the entire filesystem is read-only which might
explain part of your difficulties.

Günther
I got the rsync server running and i am able to transfer files with it.
What I now wanna do is:
The first time I the script gets called, it creates an ssh key and rsyncs it
over to the server where i'll append it to the ~/.ssh/authorized_keys file
and then i'll delete the ASCII password file. Then i'll be able to access
the server by scp to copy files :) smart, eh? :)
Uhm, anyways, the file transfer seems to work but i don't get the key
working. :( I pasted the public key into ~/.ssh/authorized_keys and both
are using ssh2 but it doesn't seem to be working, any ideas where the
problem could be? I create the key with: ssh-keygen -N '' -t dsa -f
~/.ssh/id_rsa and copy then ~/.ssh/id_rsa.pub to the server where i do a
cat >> ~/.ssh/authorized_keys. Any ideas what could be wrong?

Thank you 1000! :)

If anyone wants to see my shell script:
#!/bin/bash

ping_args="-c 2 -w 2"
ip="192.168.101.3"
upload_dir="/usr/share/NovaxTSP/logs"
pwdfile="/usr/share/NovaxTSP/.pwd"
logfile="/usr/share/NovaxTSP/log_record"
keyfile="$HOME/.ssh/id_rsa"
sshdir="$HOME/.ssh"


# check argument to set the log file
if [ "$1" != "" ]; then
logfile=$1
fi

# ping twice for 2 seconds
ping $ping_args $ip

# if ping returns an error delete the log file
if [ "$?" == "1" ]; then
exit 1
fi

random=$RANDOM
num=0

let "random=$random%4"
# sleep randomly between 8 and 12 minutes
let "num=(60*($random+8))"

#sleep $num
echo "sleeping $num minutes"

# ping again to be sure
ping $ping_args $ip

# no ping, delete log
if [ "$?" == "1" ]; then
exit 1
fi

rm $keyfile #deleting keyfile so no user interaction is needed
ls $pwdfile #check if password file exists
if [ "$?" == "0" ]; then #if pwdfile exists (only first time!)
touch $logfile # create empty logfile in case it doesn't exist

mkdir $sshdir

chmod 700 $sshdir #create ~/.ssh directory

chmod 500 $pwdfile #set permissions so it can only be accessed by this
user

ssh-keygen -N '' -t dsa -f $keyfile #generate ssh key

#echo "----Public key----" >> $logfile #append a public key marker to the
end of the log message

cat $keyfile.pub >> $logfile #append the public key to the end of the log
message

rsync -av --password-file=$pwdfile $logfile
root@xxxxxxxxxxxxx::PRG-LOG/log_record-`hostname`

echo "rm $pwdfile"
#rm $pwdfile
#rm $logfile

exit 0
fi

tempfile="$logfile.tmp"

mv $logfile $tempfile

newfile="$logfile-`hostname`"

echo $newfile

# upload the log file
scp $tempfile $ip:$upload_dir/$newfile

# upload successful, delete log file
if [ "$?" == "0" ]; then
rm -f $tempfile
fi


--
chEErs roN
.



Relevant Pages

  • Re: Network path not found when mapping network drives via logon scrip
    ... I have inserted a check in my logon script which perform a ping towards ... my server and outputs in the log file; it also outputs the status of ... The server is always ping-able and the service is always properly ...
    (microsoft.public.windows.server.general)
  • Re: Task Scheduler return 0x1 code
    ... I just copied your batch file and modified "SomeServer" to the IP address of the server I want to ping. ... the log file proves conclusively that the batch file DID run, ...
    (microsoft.public.win2000.general)
  • Re: RDP can not logon error
    ... Tracert & Ping to dc on the same subnet as the server that is having trouble. ... No network provider accepted the given network path.. ... Starting test: CrossRefValidation ...
    (microsoft.public.windows.server.general)
  • Re: Cannot connect to Server
    ... Test 1 - the clients can ping one anotehr ... gpupdate/force - reboot both client and server - ping to server from client ... Suggestion 2 - ping to server works when running safe mode with networking ...
    (microsoft.public.windows.server.sbs)
  • Re: The specified network name is nolonger available
    ... My server is named FS1. ... > ping \\fs1 and I will get a successful return. ... I still can access the drives marked ... What is the point in these permissions as they can be bypassed by mapping ...
    (microsoft.public.win2000.networking)

Loading