SSH » History » Version 7
Denis 'GNUtoo' Carikli, 05/21/2017 08:13 AM
| 1 | 1 | Denis 'GNUtoo' Carikli | h1. SSH |
|---|---|---|---|
| 2 | 2 | Denis 'GNUtoo' Carikli | |
| 3 | 1 | Denis 'GNUtoo' Carikli | h2. Server |
| 4 | |||
| 5 | This tutorial was tested on Replicant 6.0, it might or might not work on older Replicant versions. |
||
| 6 | |||
| 7 | 5 | Denis 'GNUtoo' Carikli | This tutorial assumes that: |
| 8 | 7 | Denis 'GNUtoo' Carikli | * You already setup adb and gave it root access |
| 9 | 5 | Denis 'GNUtoo' Carikli | * You already know how to use OpenSSH. |
| 10 | * You already generated some SSH keys on your computer. |
||
| 11 | 3 | Denis 'GNUtoo' Carikli | |
| 12 | 1 | Denis 'GNUtoo' Carikli | First, connect your smartphone or tablet to your computer trough USB, and make sure that ADB is already setup. If it is not, you can follow the [[ADB|explanations on how to setup ADB]]. |
| 13 | |||
| 14 | Then on your computer, make sure to give adb root permissions: |
||
| 15 | <pre> |
||
| 16 | $ adb root |
||
| 17 | </pre> |
||
| 18 | |||
| 19 | 3 | Denis 'GNUtoo' Carikli | OpenSSH requires some host keys to work, generate them on your smartphone/tablet with: |
| 20 | 1 | Denis 'GNUtoo' Carikli | <pre> |
| 21 | $ adb shell "/system/bin/ssh-keygen -A" |
||
| 22 | </pre> |
||
| 23 | |||
| 24 | OpenSSH also needs a configuration file in /data/ssh/sshd_config, and by default the /data/ssh/sshd_config doesn't exist. Since we have an example configuration file in /etc/ssh/sshd_config, we can use it. |
||
| 25 | |||
| 26 | 3 | Denis 'GNUtoo' Carikli | First copy the smartphone/tablet's /etc/ssh/sshd_config to your computer. |
| 27 | 1 | Denis 'GNUtoo' Carikli | <pre> |
| 28 | $ adb pull /etc/ssh/sshd_config |
||
| 29 | </pre> |
||
| 30 | |||
| 31 | 6 | Denis 'GNUtoo' Carikli | Then comment the line with "HostKey /data/ssh/ssh_host_dsa_key" by prepending a "#" in front of the line, to make it look like that: |
| 32 | <pre> |
||
| 33 | # HostKey /data/ssh/ssh_host_dsa_key |
||
| 34 | </pre> |
||
| 35 | When the bug #1805 will be fixed, this step will be unnecessary. |
||
| 36 | |||
| 37 | Then edit the file if you wish to change other configuration options. |
||
| 38 | |||
| 39 | then copy it to /data/ssh/sshd_config on the smartphone/tablet: |
||
| 40 | 1 | Denis 'GNUtoo' Carikli | <pre> |
| 41 | $ adb push sshd_config /data/ssh/sshd_config |
||
| 42 | </pre> |
||
| 43 | |||
| 44 | 3 | Denis 'GNUtoo' Carikli | Then, to permit accessing the smartphone/tablet with your SSH key, you need to copy your public key to the smartphone/tablet. This can be done with: |
| 45 | 1 | Denis 'GNUtoo' Carikli | <pre> |
| 46 | $ adb push ~/.ssh/id_rsa.pub /data/ssh/authorized_keys |
||
| 47 | </pre> |
||
| 48 | |||
| 49 | 7 | Denis 'GNUtoo' Carikli | First get a root shell on the smartphone/tablet with: |
| 50 | 1 | Denis 'GNUtoo' Carikli | <pre> |
| 51 | $ adb root |
||
| 52 | 7 | Denis 'GNUtoo' Carikli | $ adb shell |
| 53 | </pre> |
||
| 54 | Then you can start OpenSSH with: |
||
| 55 | <pre> |
||
| 56 | root@i9300:/ # /system/bin/sshd |
||
| 57 | 1 | Denis 'GNUtoo' Carikli | </pre> |
| 58 | 3 | Denis 'GNUtoo' Carikli | |
| 59 | 1 | Denis 'GNUtoo' Carikli | Note that OpenSSH won't be started automatically at boot, so after rebooting the smartphone/tablet, it will need to be started again manually. |
| 60 | |||
| 61 | 5 | Denis 'GNUtoo' Carikli | You should then be able to ssh into the smartphone/tablet. For instance, if you connect to it trough WiFi and that it's IP address is 192.168.43.1, you can do it this way: |
| 62 | 1 | Denis 'GNUtoo' Carikli | <pre> |
| 63 | $ ssh root@192.168.43.1 |
||
| 64 | </pre> |