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