How to copy a directory from remote to home

From my FreeBSD mate-desktop I can copy directories and files to my VPS using cat. I use user or root since it disconnect after the operation has completed.:
Code:
cat /root/MyFolder | ssh root@100.101.102.104 -p 2222 'cat >>MyFolder'
I don’t how to reverse this action. I need to import a directory from my remote machine onto my desktop. My IP is not static but can it still work? My Firewall has good rules and I use a higher port number other then 22. Would this be fairly safe?
 
I suggest you look into net/rsync, much easier to use and will be able to sync only the changes, not everything.

push: rsync -avr /some/local/dir rome0@remote:/remote/dir
pull: rsync -avr rome0@remote:/remote/dir /some/local/dir

I don’t how to reverse this action. I need to import a directory from my remote machine onto my desktop.
ssh rome0@100.101.102.104 -p 2222 'cat MyFolder' | cat << /root/MyFolder
 
Don't use cat to copy files. For simple file transfer use scp(1) as it's part of the OS and you don't have to install anything. If you need to mirror the content of the folders and copy only the changes then use rsync(1)
 
What's wrong with scp -r -P 2222 MyFolder rome0@100.101.102.104:/root/MyFolder ?
Nothing wrong with that. Except it always copies everything and you'll need to start over if the connection drops halfway through. It also won't remove files on the other end if they've been removed locally.
 
I suggest you look into net/rsync, much easier to use and will be able to sync only the changes, not everything.

push: rsync -avr /some/local/dir rome0@remote:/remote/dir
pull: rsync -avr rome0@remote:/remote/dir /some/local/dir

Yeap, I notice for a long tiime everyone who use FreeBSD as a server vote rsync(1). It's going to solve lots of problems before even getting started. System backup and everything!

VladiBG, I see what you mean.... cat is ok for text-files (copying, appending and such) … I did lots of testing and I see it only works for regular files. If there is a binary file in there you got problems. So I'll keep the few below as a reminder.

I also got into some rsync(1) and now I know when rsync(1) is to be use. For now it takes these tools to build for it, because when I’m finish hopefully nothing much will need changing until flying cars become common place.
The best I got to work:
Code:
scp -P 2222 -r ~/pfmod/* rome0@100.101.102.104:FILES/
Just saw xtaz format today, so I am on track.
Code:
scp -r -P 2222 ~/pfmod/* rome0@100.101.102.104:FILES/
The best of cat usage:
Code:
cat ~/.history_backup | ssh rome0@100.101.102.104 -p 2222 'cat >>.history_backup'
. . . .
cat /root/MyFolder | ssh root@100.101.102.104 -p 2222 'cat >>MyFolder'

That’s about all she wrote. Also, I cross-up from the start because cat don't do directories, or can it? I could swear I did a full directory with cat. As far as files, that is a sure thing. If I did it before I'll bump into it again.
 
Last edited:
VladiBG, when you said *Don't use cat to copy files* I needed to know why because I got cat code that can copy files. So now I’m looking for the diff other then cat limitations with binary files and directories. Security should be the same because they both go thru the encrypted ssh tunnel I guest. But I’m with you VladiBG, scp encrypt the data too.

I have 30 files on my desktop in a directory call .setup.

scp command did not copy one file but it did copy the other 29 files to the remote. Notice how it acted up showing parts of the .cshrc regardless of what you use.
...............................................................
Code:
(~) scp -P 2002 -r /.setup/* rome0@100.101.102.104:SETUP/
rome0@100.101.102.104's password:
echotc: Unknown capability `md'.
echotc: Unknown capability `AF'.
echotc: Unknown capability `AF'.
echotc: Unknown capability `AF'.
echotc: Unknown capability `me'.

I had to copy the dot-file by itself and scp verified the copy:
Code:
(~) scp -P 2002 -r /.setup/.cshrc rome0@100.101.102.104:SETUP/.cshrc
rome0@100.101.102.104's password:
echotc: Unknown capability `md'.
echotc: Unknown capability `AF'.
echotc: Unknown capability `AF'.
echotc: Unknown capability `AF'.
echotc: Unknown capability `me'.
.cshrc                    100% 2835    98.4KB/s   00:00

cat worked perfectly well for copy-file but it did not output the name of file:
Code:
(~) cat /.setup/.cshrc | ssh rome0@100.101.102.104 -p 2002 'cat >SETUP/.cshrc'
rome0@100.101.102.104's password:
echotc: Unknown capability `md'.
echotc: Unknown capability `AF'.
echotc: Unknown capability `AF'.
echotc: Unknown capability `AF'.
echotc: Unknown capability `me'.

Although I went off topic (seeking remote --> desktop <- from desktop ideas) what cause this limitation with scp? Can scp copy all the files at once, if so, what am I’m missing? Other then that scp is a wonderful tool.
 
The above is from tcsh try with sh or csh.

scp -P 2002 .testdotfile rome@100.101.102.104:.testdotfile

cat doesn't copy the file. It read the sequentially from the given file and output it to the stdout where you can pipe that information to another process or write it to the file.
 
The above is from tcsh try with sh or csh.

scp -P 2002 .testdotfile rome@100.101.102.104:.testdotfile

cat doesn't copy the file. It read the sequentially from the given file and output it to the stdout where you can pipe that information to another process or write it to the file.


I got enough out of this to get some things done with full confidents. Before night falls, all buffers will be buffed and use properly. :D

A File - from remote to me:
Code:
scp -P 2222 rome0@100.101.102.104:n.txt /n.txt

A Directory - from remote to me:
Code:
scp -r -P 2222 rome0@100.101.102.104:FOLDER /FOLDER
.
bad a** FreeBSD

Thanks everybody!
.
 
Back
Top