Project

General

Profile

SSH » History » Version 6

Denis 'GNUtoo' Carikli, 05/19/2017 10:28 AM
workaround bug #1805

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
* You already know how to use OpenSSH.
9
* You already generated some SSH keys on your computer.
10 3 Denis 'GNUtoo' Carikli
11 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]].
12
13
Then on your computer, make sure to give adb root permissions:
14
<pre>
15
$ adb root
16
</pre>
17
18 3 Denis 'GNUtoo' Carikli
OpenSSH requires some host keys to work, generate them on your smartphone/tablet with:
19 1 Denis 'GNUtoo' Carikli
<pre>
20
$ adb shell "/system/bin/ssh-keygen -A"
21
</pre>
22
23
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.
24
25 3 Denis 'GNUtoo' Carikli
First copy the smartphone/tablet's /etc/ssh/sshd_config to your computer.
26 1 Denis 'GNUtoo' Carikli
<pre>
27
$ adb pull /etc/ssh/sshd_config
28
</pre>
29
30 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:
31
<pre>
32
# HostKey /data/ssh/ssh_host_dsa_key
33
</pre>
34
When the bug #1805 will be fixed, this step will be unnecessary.
35
36
Then edit the file if you wish to change other configuration options.
37
38
then copy it to /data/ssh/sshd_config on the smartphone/tablet:
39 1 Denis 'GNUtoo' Carikli
<pre>
40
$ adb push sshd_config /data/ssh/sshd_config
41
</pre>
42
43 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:
44 1 Denis 'GNUtoo' Carikli
<pre>
45
$ adb push ~/.ssh/id_rsa.pub /data/ssh/authorized_keys
46
</pre>
47
48
Then you can start OpenSSH with:
49
<pre>
50
$ adb root
51
$ adb shell "/system/bin/sshd"
52
</pre>
53 3 Denis 'GNUtoo' Carikli
54 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.
55
56 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:
57 1 Denis 'GNUtoo' Carikli
<pre>
58
$ ssh root@192.168.43.1
59
</pre>