So first off thanks to spaceinvader for the groundwork:
https://www.youtube.com/watch?v=TSlHEBR1yfY
I decided to take this idea a bit further as I wanted to use SFTP with public key encryption to keep everything encrypted and I prefer to use open source software whenever possible. This took way longer then I care to admit to get working properly even though the end result is fairly simple.
Also his video is an older version of unraid, the keyfile is no longer stored, so you have to create it yourself.
This could be setup on an sftp web server if you trust it enough. or use the android app below.
You will need to setup your phone to have a static IP address with your router for this to work. A static ip on your phone directly can work as well, but router is a better option.
Install primitive ftpd on android, it is free and open source, I prefer to download from f-droid store.
https://f-droid.org/en/packages/org.primftpd/
run primitive ftpd
Select plain old file system and pick a folder you want to use (depending on version of android, you might need to use another file system, test and see what works for you, you can enable a password / not enable keys and use filezilla to test the connection before moving onto unraid)
in settings:
Disable all unsecrured log in / protocals including only starting sftp server
Add username "unraid"
remove password
set sftp port to 2785
enable public key log in and make note of folder it wants the public key to be stored in
I would also add the allowed IP pattern. Simply enter the LAN ip address of the unraid server (can use a * for the last number if the IP changes or you want more then just the unraid server to accsess the phone). This will prevent anyone not on a LAN from accessing the sftp server.
Copy public key from unraid flash drive to temp share:
cp /boot/config/ssh/ssh_host_rsa_key.pub /path/to/share/here
Or just use file explorer to browse the flash drive if it is exported.
rename the public key "authorized_keys"
Copy to phone
place the file in ".ssh" folder on main storage (it tells you correct folder in the primitive ftpd app), create if needed
Command to create keyfile:
Quick and dirty Side note, if you just want to build your array with encryption now since it is a royal pain to change later, you can simply add the below command directly to the go file. It is not secure but will get you going and you can get more advanced later. It is still better then nothing, simply yank the unraid USB and power cord from the computer and everything is secure.
Personally I would recommend using an encrypted array if you think there is any chance you might wish you had it in the future, much much better to do it when first setting up unraid then trying to swap over later.
echo -n 'password_here' > keyfile
You will most likely need to change permissions to be able to copy it to your phone:
chmod ugo+rwx keyfile
Edit: This is technically an optional step but I would highly recommend it as it is far more secure and does not expose your actual array password in plain text.
1: Install p7zip from the nerdtools plugin (install nerdtools plugin if you have not already then search for p7zip)
2: Open terminal after the keyfile exists in root (of if doing this from the start, do this step just after creating the keyfile)
3: Run this command substituting a password of your choosing, do not use your array password as this password will be stored in plain text on the USB drive.
7z a -p'Password here no space between the p' -mx=9 -mhe -t7z key.7z keyfile
copy it to temp share like before
cp key.7z /path/to/share/here
Copy to ftp folder you setup on phone
This is the command to copy the keyfile to the server, be sure to update the IP address to yours:
sftp -v -P 2785 -o identityfile=/boot/config/ssh/ssh_host_rsa_key unraid@FTP_IP_Address_Here:key.7z /root/key.7z
Run this at least once directly on the server as it will ask you to confirm the connection and we need the file it creates
Type "yes" at the prompt to remember the connection otherwise it will not work at boot.
Now we need to copy the known_hosts file to the USB drive so it can be restored at boot
cp .ssh/known_hosts /boot/config/ssh/known_hosts
Make sure the sftp command worked by typing "ls" (LS but lower case) at root@NAS:~#
Once you verified it is working, you just need to add it to the go file for unraid.
Use notepad++ and open the go file in flash/config, do not use normal notepad, it will cause issues
Paste in the below lines as new lines in the go file.
mkdir -v /root/.ssh
cp -v /boot/config/ssh/known_hosts /root/.ssh/known_hosts
sftp -v -P 2785 -o identityfile=/boot/config/ssh/ssh_host_rsa_key unraid@your_ftp_address_here:key.7z /root/key.7z
7z x -p'unraidkeyfilepassword' /root/key.7z -o/root/
reboot and test it out.
You should be able to see the output from these commands as the last few lines on the console at boot before it lists the IP address