Transferring files with OpenSSH
Posted by Anonymous on Mon 11 Oct 2004 at 12:49
OpenSSH is a well known program which allows you to login to a host remotely, and run commands etc. It also comes with a simple file transfer system which can be used to transfer files securely.
scp is the command to use. You can either transfer files to the remote machine from your local one, or vice versa.
Usage is as simple as:
scp file-to-send user@host:/path/to/place/file
For example to copy the password file from your local machine (bennevis to a remote server called 'earth' you could use:
steve@bennevis:~$ scp /etc/passwd steve@earth: steve@earth's password: passwd 100% |*****************************| 918 00:00
As no destination directory was specified the file will be transferred to your home directory upon the remote machine.
If you wish to transfer a lot of files you can copy a directory recurisvely, with the -r flag.
When it comes to sending files to and from you Unix machine from a Windows desktop you can use the excellent open source program WinSCP which presents a drag and drop interface to remote file systems - allowing you to drag and drop files with ease.
With OpenSSh installed you have no reason to be running insecure systems such as FTP to copy files to and from your Unix servers.
Beware copying many files with scp (like maybe backing up a filesystem) it doesn't seem to maintain permissions too well.. :/ (Tardis recently learnt the hard way! )
[ Parent | Reply to this comment ]
[ Send Message | View Steve's Scratchpad | View Weblogs ]
scp will preserve permissions if you use '-p' when copying...
-- Steve.org.uk
[ Parent | Reply to this comment ]
will that work if something is setgid? :/
[ Parent | Reply to this comment ]
[ Send Message | View Steve's Scratchpad | View Weblogs ]
Looks like it:
root@earth:~# touch t root@earth:~# chown root:root t root@earth:~# chmod 2755 t root@earth:~# ls -ltr total 4 drwx------ 2 root root 4096 Jun 29 14:40 Mail -rwxr-sr-x 1 root root 0 Oct 18 09:30 t root@earth:~# scp -p t localhost:/tmp root@localhost's password: t 100% |*****************************| 0 00:00 root@earth:~# ls -l /tmp/t -rwxr-sr-x 1 root root 0 Oct 18 09:30 /tmp/t
-- Steve.org.uk
[ Parent | Reply to this comment ]
Ah good. Thanks for testing.
[ Parent | Reply to this comment ]
Felipe Sateler
[ Parent | Reply to this comment ]