SSH File Transfers |
Though FTP has been commonly used in the School of Computing and by
many other sites across the globe, it suffers a severe lack of security
by passing a user's login information, including their password, via
plain text across the network. In order to avoid such a blatent security
hole, we are using the encrypted SSH protocol for logins and file
transfers. This document is meant to be a quick guide on
using SSH/SFTP for file transfers on UNIX and Windows machines.
Unix - UnixTransferring files between two Unix systems using SSH is handled by two simple command line programs, scp and sftp.SCPI'm using SCP, for saving transfer time, If you have a few files or big files to transfer, you can save time by using the scp command instead of sftp. scp works much like rcp, for those who are familiar with the remote shell tools. All interaction is handled on the command line. File transfers can be done in either direction. Using the same files from our example above, transferring them using scp would work like this:> scp "remotemachine:/server/homework/*.txt" . myfile1.txt | 3 KB | 3.3 kB/s | ETA: 00:00:00 | 100% myfile2.txt | 0 KB | 0.8 kB/s | ETA: 00:00:00 | 100% myfile3.txt | 6 KB | 6.3 kB/s | ETA: 00:00:00 | 100% > or something like this
$ sudo scp "user@remote:/from/public/dir\ some\ place\ you\ have/*" toyourdir/ user@remote's password:
Transferring files to a remote machine is done in much the same way: > scp *.txt remotemachine:. myfile1.txt | 3 KB | 3.3 kB/s | ETA: 00:00:00 | 100% myfile2.txt | 0 KB | 0.8 kB/s | ETA: 00:00:00 | 100% myfile3.txt | 6 KB | 6.3 kB/s | ETA: 00:00:00 | 100% > SFTPAs the name might imply, sftp works much like a regular ftp client, but transfers are all made across an encrypted channel. To establish a secure ftp connection to a machine, simply use:sftp You will be prompted for your password/passphrase and then dropped into an ftp-like prompt. Typing a "?" at the prompt will show you supported commands. sftp> ? Available commands: cd path Change remote directory to 'path' lcd path Change local directory to 'path' chgrp grp path Change group of file 'path' to 'grp' chmod mode path Change permissions of file 'path' to 'mode' chown own path Change owner of file 'path' to 'own' help Display this help text get remote-path [local-path] Download file lls [ls-options [path]] Display local directory listing ln oldpath newpath Symlink remote file lmkdir path Create local directory lpwd Print local working directory ls [path] Display remote directory listing lumask umask Set local umask to 'umask' mkdir path Create remote directory put local-path [remote-path] Upload file pwd Display remote working directory exit Quit sftp quit Quit sftp rename oldpath newpath Rename remote file rmdir path Remove remote directory rm path Delete remote file symlink oldpath newpath Symlink remote file version Show SFTP version !command Execute 'command' in local shell ! Escape to local shell ? Synonym for help sftp> The actual file transfer process is handled with the get and put commands. For our example, lets say that you want to grab a couple of files off of a remote Unix machine, which are located in /server/homework. Once you have connected and entered your password, you would simple use: cd /server/homework sftp> ls myfile1.txt myfile2.txt myfile3.txt sftp> sftp> get *.txt myfile1.txt:.................................................................. 3397 bytes received in 0.03 secs, 104.90 K/s myfile2.txt:.................................................................. 791 bytes received in 0.01 secs, 56.70 K/s myfile3.txt:.................................................................. 6441 bytes received in 0.02 secs, 219.65 K/s sftp> . Please refer to the man pages for sftp and scp references beyond the scope of this guide. |
No comments:
Post a Comment