Unattended (S)FTP up- and downloading

Hi,

I require a solution for a need that I have: Up until now I have up- and downloaded from my remote SFTP server with my Windows PC and some FTP client. Now that I have the turris I would imagine to let it do the work.

My turris has HDDs attached to it. Can I initiate an unattended download or upload of any content from/to there with my router? I have found lftp and think it can handle such a task but so far I haven’t been able to get it to do that. I have looked over the lftp manpage.

Has anyone done such a thing? I appreciate any pointers to guides or specifics.

Thanks.

UPDATE
I found that lftp does the job I rquire perfectly. Learning to handle it properly is my job now. Thanks @milos @adminX for helping me along.

For all who are interested, here is a clear-cut guide for lftp by whatbox: https://whatbox.ca/wiki/lftp

You could try with command line option ‘-d’ to see what happens.

To run a program in the background install and use “screen”. That way the program is not cancelled when you disconnect the ssh session.

But I believe you may bee looking for something with a graphical user unterface?

1 Like

@JamesT42 Actually, no, not necessarily. Of course, if there is such a thing for OpenWrt I’d want to use it. I would be content with a working command line interface that allows me to upload files with my turris unattended to my SFTP server.

Do you happen to have experience with lftp? I have it installed and am able to log into my SFTP server. I haven’t been able to figure out the right command line to initiate an upload, however. The manpage of lfpt does not give me any clue about whether or not it can handle local files, in my case my mounted HDDs.

The command line I tried from within the folder on the SFTP server I want to upload to looks like this:

mput "/mnt/hdd2/somedirectory/*.*"

The output of lftp is ‘no files found’.

No, maybe you want to try mc (midnight commander). It has a rudimentary graphical interface.

This is a filemanager only, no ftp capability… no?

http://iboris.com/news/mc-file-manager-gui-sftp-support.html

1 Like

@JamesT42 Sweet! Thanks!

@JamesT42

I tried to connect to my SFTP server with

cd #sh:yourusername@example.com:/home/username/

within the MC interface as suggested here. MC outputs Error Cannot chdir to

Any ideas?

Try cd sh://yourusername@example.com:[port]/home/username or enter your connection details via F9 > Shell link in the form yourusername@example.com:[port]/home/username/

I suppose you have replaced yourusername, example.com and /home/username with your actual user name, the address of your server and an existing directory on your server.

Defining the port and the directory is optional, so you can also try to omit them.

Another questions are, if you are allowed to ssh into the remote host (which is usually not the case f.ex. with shared hosting) and if sshd is running.

1 Like

Using mc is not exactly unattended.

I use lftp to upload static files to my hosting. I have this line in my deploy script:

lftp -c "set ftp:ssl-allow no; open -u $FTP_USER,$FTP_PASS $FTP_HOST; mirror -Rnev $SRC $DEST"

You have of course to define the variables somewhere or replace them with your details.

1 Like

@milos

Of course. :smirk: What would I be if I hadn’t?! A dummy… :laughing: :wink:

Yes, the remote host allows me to SFTP/SSH into it.

I was thinking to use it together with screen as suggested by @JamesT42

You say deploy script. Would you like to elaborate? I am interested and new to the linux world and writing of scripts.

I’ll try out the command line. Thank you @milos!

@JamesT42 Using MC I find it is buggy, on the turris at least. I installed it yesterday and it worked fine. This morning I want to launch it and get

:confused:

This has been reported recently. Try to delete /etc/mc/history. That worked for me.

Source: https://www.turris.cz/forum/topic_show.pl?tid=1484.
Google translated EN version here

2 Likes

Thank you very much @Kes

I build my site using a static site generator. I take advantage of a version control system and a continuous integration service.
The script controls the CI flow. It says something like: When there is a new commit to master branch, build the site and if the build is OK, upload the files to the hosting.

1 Like

@milos Thanks. You seem to know your stuff.

It sounds probably more complicated than it is :relaxed:

@milos Tried the command and get this result even though all login info is correct:

May be a problem on the remote servers end? Maybe it won’t let me log in. I can login with these credentials via ssh and any windows based sftp client. Is the ftp:ssl-allow no required?

Just noticed that the set belongs to the ssl-allow bit. Removed it. Same result.

It is lftp -c "open sftp://$FTP_USER:$FTP_PASS@$FTP_HOST ; mirror -Rnev $SRC $DEST" for sftp

Note: $SRC and $DEST with or without a trailing slash make a difference.

1 Like