selfprivacy.org/content/en/docs/How To Guides/root_ssh/_index.md

107 lines
3.6 KiB
Markdown
Raw Normal View History

---
title: "How to get root access via SSH"
2023-03-15 14:58:09 +00:00
linkTitle: "Root access via SSH"
weight: 1
date: 2023-03-14
description: >
If you need to manually perform some tasks, you can get root access via SSH.
categories: ["How-To Guides"]
---
To access your server's root shell you will have to generate your SSH key and add it to your server's authorized keys.
## How to generate SSH key
2023-08-30 17:42:51 +00:00
{{< tabpane text=true >}}
{{% tab "Unix-like systems (PC)" %}}
2023-09-01 15:42:08 +00:00
### If you are a Unix-like system user
1. Open the terminal.
2. Run the following command:
```bash
ssh-keygen -t ed25519 -f ~/.ssh/id_ed25519
```
You will be asked to enter a passphrase. You can leave it empty, but it is recommended to use a passphrase.
If you do not want to use a passphrase, press **Enter**.
3. Print the public key to the terminal and copy it:
```bash
cat ~/.ssh/id_ed25519.pub
```
4. Refer to the next section to add the key to your server.
2023-08-30 17:42:51 +00:00
{{% /tab %}}
{{% tab "Windows" %}}
2023-09-01 15:42:08 +00:00
### If you are a Windows user
1. Open settings and under "Applications" click on "Manage additional components".
2. Press "Add Component".
3. Enter "OpenSSH client" in the search box and install it.
4. Open the Command Prompt. You can do this by pressing **Win+R**, typing `cmd` and pressing **Enter**.
5. Run the following command, replacing `user_name` with your Windows username:
```ps1
2024-01-19 12:24:20 +00:00
ssh-keygen -t ed25519 -f C:\Users\user_name\.ssh\id_ed25519
```
You will be asked to enter a passphrase. You can leave it empty, but it is recommended to use a passphrase.
If you do not want to use a passphrase, press **Enter**.
6. Print the public key to the terminal and copy it:
```ps1
type C:\Users\user_name\.ssh\id_ed25519.pub
```
Once again, replace `user_name` with your Windows username.
7. Refer to the next section to add the key to your server.
2023-08-30 17:42:51 +00:00
{{% /tab %}}
{{% tab "Android (Termux)" %}}
2023-09-01 15:42:08 +00:00
### If you are a Android (Termux) user
0. Install [Termux](https://termux.dev/en/). We recommend installing it from F-Droid.
1. Open Termux.
2. Run the following command:
```bash
apt update -y && apt upgrade -y && apt install open-ssh -y &&
ssh-keygen -t ed25519 -f /data/data/com.termux/files/usr/etc/ssh/ssh_host_ed25519_key
```
You will be asked to enter a passphrase. You can leave it empty, but it is recommended to use a passphrase.
If you do not want to use a passphrase, press **Enter**.
3. Print the public key to the terminal and copy it:
```bash
cat /data/data/com.termux/files/usr/etc/ssh/ssh_host_ed25519_key.pub
```
4. Refer to the next section to add the key to your server.
2023-08-30 17:42:51 +00:00
{{% /tab %}}
{{< /tabpane >}}
## How to add the key to your server
0. Open the SelfPrivacy app.
1. Go to the "More" tab.
2. Tap on "Superuser SSH keys".
3. Tap on the "Create SSH key" button.
4. Paste the public key you copied earlier.
5. Tap on the "Create SSH key" button.
6. Open the Jobs list
7. Tap on the "Start" button.
8. In a few minutes, you will be able to access your server's root shell via SSH.
2023-08-30 17:17:25 +00:00
{{< imgproc more-superuser Fill "1001x808" />}}
2023-08-30 17:42:51 +00:00
## How to access your server's root shell via SSH
1. Open the terminal or Command Prompt.
2023-08-25 11:13:26 +00:00
2. Run the following command, replacing `server_domain` with your server's domain:
```bash
ssh root@server_domain
```
3. Enter the passphrase you entered when generating the SSH key, if you used one.
Be careful when using the root shell. If you do not know what you are doing, you can break your server or leak your data.
2024-01-19 12:24:20 +00:00
Responsibility for the consequences of your actions lies with you. Respect the privacy of other users.