Re: remote copy file
- From: Ron Eggler <test@xxxxxxxxxxx>
- Date: Tue, 18 Mar 2008 16:42:20 GMT
Günther Schwarz wrote:
Ron Eggler wrote:Günther
Günther Schwarz wrote:
Ron Eggler wrote:
Nikos Chantziaras wrote:
Nikos Chantziaras wrote:I'm not sure if you understood my problem right. I have an embedded
[...]
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."
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.
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
.
- Follow-Ups:
- Re: remote copy file
- From: Ron Eggler
- Re: remote copy file
- References:
- remote copy file
- From: Ron Eggler
- Re: remote copy file
- From: Nikos Chantziaras
- Re: remote copy file
- From: Ron Eggler
- Re: remote copy file
- From: Nikos Chantziaras
- Re: remote copy file
- From: Nikos Chantziaras
- Re: remote copy file
- From: Ron Eggler
- Re: remote copy file
- From: Günther Schwarz
- Re: remote copy file
- From: Ron Eggler
- Re: remote copy file
- From: Günther Schwarz
- remote copy file
- Prev by Date: Re: rsa key problem
- Next by Date: Re: remote copy file
- Previous by thread: Re: remote copy file
- Next by thread: Re: remote copy file
- Index(es):
Relevant Pages
|
Loading