Project

General

Profile

SSH » History » Version 5

Denis 'GNUtoo' Carikli, 05/19/2017 08:00 AM
clarify

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 4 Denis 'GNUtoo' Carikli
Then edit the file if you wish to change configuration options, and copy it to /data/ssh/sshd_config on the smartphone/tablet:
31 1 Denis 'GNUtoo' Carikli
<pre>
32
$ adb push sshd_config /data/ssh/sshd_config
33
</pre>
34
35 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:
36 1 Denis 'GNUtoo' Carikli
<pre>
37
$ adb push ~/.ssh/id_rsa.pub /data/ssh/authorized_keys
38
</pre>
39
40
Then you can start OpenSSH with:
41
<pre>
42
$ adb root
43
$ adb shell "/system/bin/sshd"
44
</pre>
45 3 Denis 'GNUtoo' Carikli
46 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.
47
48 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:
49 1 Denis 'GNUtoo' Carikli
<pre>
50
$ ssh root@192.168.43.1
51
</pre>