SSH straight to specific directory

Post your questions and help other users.

Moderator: Martin

User avatar
beelze
Posts: 46
Joined: 04 Nov 2018 16:45

Re: SSH straight to specific directory

Post by beelze » 23 Nov 2018 08:00

What exactly you're trying to automate?
E.g. «upload relatively small file» or «upload a big file» or «keep in sync large project' file/dir structure»?

For the last 2 cases better to use rsync (over ssh) or any «home cloud», because they support resuming broken transfers and effective implementation of different sync strategies. If you like ssh as transport, you need to properly tune ssh server (dedicated non-root user, ChrootDirectory+ForceCommand, PermitRootLogin=no, only pubkey auth and maybe something else).

BTW, my android has both scp and rsync out-of-the-box.

User avatar
digitalstone
Posts: 342
Joined: 21 Oct 2017 12:36
Location: The Netherlands

Re: SSH straight to specific directory

Post by digitalstone » 24 Nov 2018 11:04

Well one example of file automation is of course, the Automagic backup .zip-file.
It would be cute to leave it on the local device, but better to have it backed up at my server together with all other backups.
That particular backup-flow for instance, will have to transfer that file to the server every day
Don't want to do that every day manually through another specific app... which could technically work, and probably will, but with automation-type-stuff i'd like it my own way.
Phone: LG Nexus 5X (rooted vanilla Android 7.1.2)

User avatar
beelze
Posts: 46
Joined: 04 Nov 2018 16:45

Re: SSH straight to specific directory

Post by beelze » 24 Nov 2018 20:28

Well, thus you need rsync over ssh.

1. it is just secure as ssh (I've already wrote a couple of words about ssh security)
2. rsync can be used everywhere (and using almost same syntax) instead scp
3. you can skip files that are newer on the receiver (--update)
4. you can keep partially transferred files, which should make a subsequent transfer of the rest of the file much faster (--partial)
5. you can use compression during transfer (--compress, --compress-level, --skip-compress=SUFFIXES)
6. you can remove from the sending side the files that have been successfully duplicated on the receiving side (--remove-source-files)
7. you can specify list of files to transfer (-files-from=FILE), so if you need to include another one file to your backup process, there is no need to change the code and command line, just edit FILE

and many more, consider man rsync

User avatar
digitalstone
Posts: 342
Joined: 21 Oct 2017 12:36
Location: The Netherlands

Re: SSH straight to specific directory

Post by digitalstone » 25 Nov 2018 21:07

Not sure why you're trying to get me to use this rsync though. It has nothing to do with automation.
Synchronization functionality can be easily created within AM already, and continuing partial files are pretty sad. It means you have either no patience or very bad network connection to begin with. So if either one of those, let's start solving problems at their core.
Phone: LG Nexus 5X (rooted vanilla Android 7.1.2)

User avatar
beelze
Posts: 46
Joined: 04 Nov 2018 16:45

Re: SSH straight to specific directory

Post by beelze » 26 Nov 2018 02:40

digitalstone wrote:rsync though. It has nothing to do with automation.
Very unexpected. Why do you think so? I'm using rsync (mostly indirectly) every day. Getting package updates, syncing backup chains between servers and workstations, even for moving hot data among the drives. As I said before, for a simple use cases the basic syntax for the scp and rsync/ssh upload is the same:

Code: Select all

<scp|rsync> /local/file user@server:/path/
About transfer resuming: there are more scenarios for this aside from bad connectivity. In any way, it's better to have such a functionality (if you can turn it on and off wherever needed)

Post Reply