Project

General

Profile

SSH » History » Version 11

Denis 'GNUtoo' Carikli, 04/25/2019 09:25 PM
add forgetten $PS1

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 7 Denis 'GNUtoo' Carikli
* You already setup adb and gave it root access
9 5 Denis 'GNUtoo' Carikli
* You already know how to use OpenSSH.
10
* You already generated some SSH keys on your computer.
11 3 Denis 'GNUtoo' Carikli
12 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]].
13
14
Then on your computer, make sure to give adb root permissions:
15
<pre>
16
$ adb root
17 9 Denis 'GNUtoo' Carikli
$ adb shell
18 1 Denis 'GNUtoo' Carikli
</pre>
19
20 3 Denis 'GNUtoo' Carikli
OpenSSH requires some host keys to work, generate them on your smartphone/tablet with:
21 1 Denis 'GNUtoo' Carikli
<pre>
22 10 Denis 'GNUtoo' Carikli
root@i9300:/ # ssh-keygen -A
23 1 Denis 'GNUtoo' Carikli
</pre>
24
25
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.
26
27
First copy the smartphone/tablet's /etc/ssh/sshd_config to your computer.
28
<pre>
29 11 Denis 'GNUtoo' Carikli
root@i9300:/ # cp /etc/ssh/sshd_config /data/ssh/sshd_config
30 1 Denis 'GNUtoo' Carikli
</pre>
31
32 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:
33 1 Denis 'GNUtoo' Carikli
<pre>
34
$ adb push ~/.ssh/id_rsa.pub /data/ssh/authorized_keys
35
</pre>
36
37 10 Denis 'GNUtoo' Carikli
First get a root shell again on the smartphone/tablet with:
38 1 Denis 'GNUtoo' Carikli
<pre>
39
$ adb root
40 7 Denis 'GNUtoo' Carikli
$ adb shell
41
</pre>
42
Then you can start OpenSSH with:
43
<pre>
44
root@i9300:/ # /system/bin/sshd
45 1 Denis 'GNUtoo' Carikli
</pre>
46 3 Denis 'GNUtoo' Carikli
47 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.
48
49 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:
50 1 Denis 'GNUtoo' Carikli
<pre>
51
$ ssh root@192.168.43.1
52
</pre>