Difference between revisions of "How to send/get a file to/from a remote server via command line or script"

From Salix OS
Jump to: navigation, search
m
Line 19: Line 19:
  
 
  lftp sftp://user:password@host  -e "put local-file.name"
 
  lftp sftp://user:password@host  -e "put local-file.name"
 +
 +
[[category:User Documentation|FTP]

Revision as of 13:45, 15 March 2012

A system administrator might need the ability of automatic downloading or uploading a file to a remote machine via a secure protocol. Several methods can be used, however using LFTP seems to be the simplest (however a bit unsafe).

Install LFTP

 slapt-get -u
 slapt-get -i lftp

LFTP Usage

LFTP can be used as any typical FTP client but it also provides the ability to connect without asking about the password. The solution is simple however a bit unsafe as the password is given explicitly as text, like below. Thus anybody who can read the script can also steal the password, so make sure your script is readable for you only. Also, do not connect as root. Create a special user for this without root super-powers. The example below shows how to get a file from a remote server via secure SFTP protocol:

lftp sftp://user:password@host  -e "get remote-file.name"

In case the port for SSH connection is changed, then try:

lftp sftp://user:password@host:port  -e "get file.name"

To send a file to a remote server:

lftp sftp://user:password@host  -e "put local-file.name"

[[category:User Documentation|FTP]