Prep work:
- Have your phone connected to your LAN - WIFI on
- Have the app SimpleSSHD installed on your phone and running
On the Phone
- Open SimpleSSHD and go to settings via the kabab menu
- Note the Port Number
- In my case it was set to 2222
- Note (write down) the SSH Path
- in my case it was /data/user/0/org.galexander.sshd/files
- Set the Home Directory to: sdcard
- Return to the main screen of SimpleSSHD
- Note the ip address of the phone on the main screen of SimpleSSHD
- in my case it was 192.168.1.112
On your computer
- Open a terminal
- ssh into your phone using the port and ip address from above
- ssh -p 2222 192.168.1.112
- When prompted to allow this connection, type: yes and hit enter
On the phone
- On the main screen of SimpleSSHD a single-use password is displayed
On your computer
- Enter the password that is displayed on SimpleSSHD
- You are now logged in to your phone via an ssh terminal. Have a look around with ls -l and cd and note the directory structure.
- in my case the photos are located (starting at sdcard) in DCIM/Camera
- Type exit [enter] to end the ssh session
- Confirm the existence of your public ssh key on your computer with
- cat ~/.ssh/id_rsa.pub
- If the key was not found, generate one with
- ssh-keygen -t rsa -b 4096
- accept the prompt for location
- don’t use a password – leave blank
- do #16 again
- Add the port 2222 for the phone’s ip address to your ssh config file with these commands:
- echo “Host [ip addres of the phone]” >> ~/.ssh/config
- echo “Host 192.168.1.112” >> ~/.ssh/config
- echo “Port [port of the phone]” >> ~/.ssh/config
- echo “Port 2222” >> ~/.ssh/config
- echo “Host [ip addres of the phone]” >> ~/.ssh/config
- Copy your id_rsa.pub key to the phone using secure copy with
- scp ~/.ssh/id_rsa.pub [ip address of the phone]:[ssh path on the phone]/authorized_keys
- in my case it was:
- scp ~/.ssh/id_rsa.pub 192.168.1.112:/data/user/0/org.galexander.sshd/files/authorized_keys
On the phone
- SimpleSSHD now displays a newly generated, single-use password
On your computer
- Enter the password that is displayed on SimpleSSHD
- You should now be able to login to your phone with
- ssh 192.168.1.112
rsync command to copy pictures from your phone
- rsync --verbose --ignore-existing --dry-run 192.168.1.112:DCIM/Camera/* ~/Pictures
- #23 is with the --dry-run option. No action is actually performed
- rsync --verbose --ignore-existing 192.168.1.112:DCIM/Camera/* ~/Pictures
rsync command to push audio files to your phone
- rsync --verbose --ignore-existing --dry-run ~/path/to/my/audio/* 192.168.1.112:Music
- #25 is with the --dry-run option. No action is actually performed
- rsync --verbose --ignore-existing ~/path/to/my/audio/* 192.168.1.112:Music
Here is how I am using this.
I set the SimpleSSHD app to be fired by Tasker (Android scheduling app) every morning. I set a cron event on my computer to grab my new pictures from my phone. I set another cron event on my computer to push my new podcasts that were aggregated (while I slept) onto my phone for listening during the following day. (I scripted a personal aggregator for privacy and post processing reasons).