So, I just shared it all of you.
The OpenSSH suite of programs is one of my favourite toolkits for administration of servers on a LAN. I routinely use the scp command to copy files between systems and move stuff around as required. In effect, it replaces the old rcp command, but it much more secure as well as more convenient to use.
To copy files between two machines, say 192.168.1.101 and 192.168.1.100, sit at 192.168.1.101 and use the following command:
scp * 192.168.1.100:
Simple as that! Assuming you are the same user id on both machines, this will copy all files in the current directory to your home directory on the destination machine, 192.168.1.100. The first thing the command will do, though, is ask you for your password on the remote system - once you supply that, then you’ll see the files copied, with progress bars.
Now, if you want to copy only some files, e.g. all txt files, use a standard wildcard, like this:
scp *.txt 192.168.1.100:
Suppose you want to copy them to a destination directory other than your home directory, use:
scp *.txt 192.168.1.100:/home/username/directory
Of course, you have to have write permission on the target directory.
Suppose you want to copy files from the other machine back to the one you’re on - then use this syntax:
scp 192.168.1.100:*.txt .
If you have a DNS or hosts file set up, then you can (and should) use hostnames in the command, like this:
scp mail/* mailsrvr:/home/joe/mail
This will copy the contents of the mail subdirectory (of the current directory) on this machine, to the directory /home/joe/mail on the machine mailsrvr.

没有评论:
发表评论