SSH » History » Version 2
Denis 'GNUtoo' Carikli, 05/19/2017 07:52 AM
typos
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 | 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]]. |
||
8 | |||
9 | Then on your computer, make sure to give adb root permissions: |
||
10 | <pre> |
||
11 | $ adb root |
||
12 | </pre> |
||
13 | |||
14 | OpenSSH requires some host keys to work, generate them with: |
||
15 | <pre> |
||
16 | $ adb shell "/system/bin/ssh-keygen -A" |
||
17 | </pre> |
||
18 | |||
19 | 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. |
||
20 | |||
21 | First copy the device's /etc/ssh/sshd_config to your computer. |
||
22 | <pre> |
||
23 | $ adb pull /etc/ssh/sshd_config |
||
24 | </pre> |
||
25 | |||
26 | Then edit the file if you wish to change configuration options. |
||
27 | <pre> |
||
28 | $ adb push sshd_config /data/ssh/sshd_config |
||
29 | </pre> |
||
30 | |||
31 | Then permit accessing the device with your SSH key. |
||
32 | If you use the most common key format (RSA) you can do it this way: |
||
33 | <pre> |
||
34 | $ adb push ~/.ssh/id_rsa.pub /data/ssh/authorized_keys |
||
35 | </pre> |
||
36 | |||
37 | If you instead use the very recent ed25519 keys you can do it this way: |
||
38 | <pre> |
||
39 | $ adb push ~/.ssh/id_ed25519.pub /data/ssh/authorized_keys |
||
40 | </pre> |
||
41 | |||
42 | Then you can start OpenSSH with: |
||
43 | <pre> |
||
44 | $ adb root |
||
45 | $ adb shell "/system/bin/sshd" |
||
46 | </pre> |
||
47 | |||
48 | Note that OpenSSH won't be started automatically at boot, so after rebooting the device, it will need to be started again manually. |
||
49 | |||
50 | You should then be able to ssh into the device with: |
||
51 | <pre> |
||
52 | $ ssh root@192.168.43.1 |
||
53 | </pre> |