Page 1 of 2
SSH straight to specific directory
Posted: 22 Nov 2018 14:12
by digitalstone
With the Execute SSH Command action, i've been trying to transfer this file for the last few hours to my server now, along the likes of:
Command
Input File
But the only actual successful file transfer has been the root folder.
I'm probably limited by my command knowledge.
Re: SSH straight to specific directory
Posted: 22 Nov 2018 14:42
by beelze
Not quite understand what exactly you're trying to do. Transfer (copy)?
cat > file redirecting cat' output to file. So you're trying to store stdin to file. More, path separator is /, not \.
And what about input file?
Re: SSH straight to specific directory
Posted: 22 Nov 2018 15:03
by digitalstone
Yes i'm trying to transfer a file from my phone to a server through SSH (within the same network).
I saw inside the help of some other action to use this command.
scp also has been a failed attempt.
But again, my command knowledge isn't all that.
External path seperator is "\". Or do you mean this path is yet to be interpreted by the server, which makes it an internal path from there?
Re: SSH straight to specific directory
Posted: 22 Nov 2018 15:44
by beelze
You can't transfer file using ssh command. You need
scp or (more universal and versatile,
rsync)
Testing from adb shell,
scp works as expected (minimal working example):
Code: Select all
scp -o StrictHostKeyChecking=no -i /path/to/privkey.rsa /path/to/source/file myuser@myhost:/path/to/destination
Of course, myhost have corresponding pubkey in .ssh/authorized_keys (or wherever points AuthorizedKeysFile in sshd_config)
You can use
Execute [root] command to invoke scp like above.
Please explain about «External path separator», still no idea about.
Re: SSH straight to specific directory
Posted: 22 Nov 2018 15:51
by beelze
upd: it is not a good idea to connect via ssh using KbdInteractiveAuthentication/PasswordAuthentication (entering/providing password). It more secure, easy and convenient to use PubkeyAuthentication (expected to be turned on by default on any ssh server).
Re: SSH straight to specific directory
Posted: 22 Nov 2018 16:32
by digitalstone
Using pubkeys was on my to-do list so thanks for reviving that
Better trying this out both at once since they're going hand in hand.
I have not ever worked with, nor created pubkey before so this might take longer than expected. Or maybe it's easy, i don't know.
There is just no port number inside your command.
I take that it is still necessary somewhere?
And is the "StrictHostKeyChecking=no" safe at all?
With "external path separators" is just meant the backslashes you use inside a path on any terminal outside (external) the local host.
Example: \\servername\folder\file.ext
Re: SSH straight to specific directory
Posted: 22 Nov 2018 17:55
by beelze
1. I'm using standard ssh port (22) everywhere, because there is no real security improvement in using different port. There is no need to explicitly declare port 22.
2. PasswordAuth designed to be interactive (most ssh-related tools not supported password-providing command line options, nor even reading password from stdin, because is it very insecure), so you can face real problems trying to build command line providing password. Yes, you can use *expect utils, but for what? It is very simple to generate keypair and use it.
3. Use either StrictHostKeyChecking=no or maintain known_hosts file on client side. But, if server resides in the same network, I guess there is no much sense in checking server key.
4. \\servername\folder\file.ext is a windows path, isn't it? So ssh server is a Windows host? Why ssh then?
Re: SSH straight to specific directory
Posted: 22 Nov 2018 18:45
by digitalstone
Port 22 could easily be done indeed. But just having that 1 extra number to figure out the port at all makes it, in my book at least, a tiny bit more 'secure' than having just the standard 22.
I'm aware there are 2 camps on that whole debate, so you know which one i'm clinging onto now.
But that explains it then. Other than my server (Qnap) and phone, i'm a Windows user.
It did not even occur to me that there are no backslashes inside linux paths because i almost never have to type in those paths (... i just didn't pay attention).
StrictHostKeyChecking=no would then make sense yes. The server is just always the same Qnap machine in the house.
Thanks. I appreciate your time.
Re: SSH straight to specific directory
Posted: 22 Nov 2018 19:18
by beelze
It is no harm to use
-P 22 in
scp command line. But, there are 50+ another ssh options, consider
man scp and
man ssh_config
But I got another idea. If file transfer is the one and only use of ssh, why not to use something more simple and secure? E.g.
Dropbox Upload File action? Dropbox is not secure? Well, you can deploy something like
owncloud or
seafile on your server[s], there are android clients for both.
Re: SSH straight to specific directory
Posted: 22 Nov 2018 21:24
by digitalstone
Owncloud and Seafile both look like promising software. When i'm further with setting up my stuff, i will definitely dig into them.
For manual phone-to-server transfer i use ES File Explorer which i bought years ago and have no problem with.
But the whole point for now is to automatically transferring file(s) to the server. I didn't bought it for nothing, and project files, media, sensitive files and such (which take way to long to transfer through internet where i live btw) are surely not going to live somewhere on some server(s)
I mean, i'm a guy who sees a problem in using the default SSH port
Btw, i have PuTTy and WinSCP installed.
Can do some things with them if necessary.
But again, that's just manual control.
I'm more about automation to focus on other tasks.