Project

General

Profile

SSH » History » Version 4

Denis 'GNUtoo' Carikli, 05/19/2017 07:59 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 3 Denis 'GNUtoo' Carikli
This tutorial assumes that you already know how to use OpenSSH and that you already generated some SSH keys on your computer.
8
9 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]].
10
11
Then on your computer, make sure to give adb root permissions:
12
<pre>
13
$ adb root
14
</pre>
15
16 3 Denis 'GNUtoo' Carikli
OpenSSH requires some host keys to work, generate them on your smartphone/tablet with:
17 1 Denis 'GNUtoo' Carikli
<pre>
18
$ adb shell "/system/bin/ssh-keygen -A"
19
</pre>
20
21
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.
22
23 3 Denis 'GNUtoo' Carikli
First copy the smartphone/tablet's /etc/ssh/sshd_config to your computer.
24 1 Denis 'GNUtoo' Carikli
<pre>
25
$ adb pull /etc/ssh/sshd_config
26
</pre>
27
28 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:
29 1 Denis 'GNUtoo' Carikli
<pre>
30
$ adb push sshd_config /data/ssh/sshd_config
31
</pre>
32
33 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:
34 1 Denis 'GNUtoo' Carikli
<pre>
35
$ adb push ~/.ssh/id_rsa.pub /data/ssh/authorized_keys
36
</pre>
37
38
Then you can start OpenSSH with:
39
<pre>
40
$ adb root
41
$ adb shell "/system/bin/sshd"
42
</pre>
43
44 3 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.
45 1 Denis 'GNUtoo' Carikli
46 3 Denis 'GNUtoo' Carikli
You should then be able to ssh into the smartphone/tablet with:
47 1 Denis 'GNUtoo' Carikli
<pre>
48
$ ssh root@192.168.43.1
49
</pre>