andronix.docs
Step 4 · Use it

SSH

Learn how to run an SSH server on your Android device with Andronix, either from Termux (recommended) or from inside your Linux distro.

SSH lets you access your device's shell remotely. This page covers two ways to run an SSH server: from Termux and from inside your Linux distro.

We recommend running the SSH server from Termux rather than from the Linux environment. An SSH server running in Termux gives you control of both your device and your Linux OS. Both methods are described below.

SSH via Termux

Follow this guide to learn how to run an SSH server from Termux. The tutorial is officially provided by one of the Termux developers.

SSH via Linux

Since Linux runs through PRoot, it cannot override Android's default connectivity configuration, so the SSH port number needs to be changed. Follow the steps below to run SSH from Linux:

On distros from Andronix 2.0, you log in as your own user and root is locked. Put sudo in front of each command below, skip the PermitRootLogin change and the root password step, and connect as your user, for example ssh alex@192.168.xx.xx -p 2222.

Install OpenSSH

Install OpenSSH inside Linux. Pick the command for your distro from the list below:

Ubuntu

apt install openssh-server nano -y

Kali Linux

apt install openssh-server nano -y

Debian

apt install openssh-server nano -y

Manjaro

pacman -S openssh nano --noconfirm

Arch

pacman -S openssh nano --noconfirm

Fedora

dnf install -y openssh-server nano

Alpine

apk add openssh-server nano

Void

xbps-install openssh nano

Modifications

Once the OpenSSH server is installed, you need to change a few settings so it's reachable over the network despite Android's limitations. Open the SSH config file:

nano /etc/ssh/sshd_config
  • Find the line #Port 22 and change it to Port 2222.
  • Find the line #PermitRootLogin prohibit-password or #PermitRootLogin yes and change it to PermitRootLogin yes. If it already says PermitRootLogin yes, you don't need to change anything.
  • When you're done, press CTRL+X, type Y and press Enter to save.

Generate Keys

Next, generate the host keys by running:

ssh-keygen -A

and then:

ssh-keygen

Password

Now set a password for the root user by running:

passwd

Enter any password you like.

Start SSH Server

Once that's done, start the SSH server by running:

/usr/sbin/sshd

Connect

Run the following command:

ip a

and copy the IP address listed under wlan. To connect to the SSH server, run:

ssh root@localhost -p 2222

and log in with the password you set earlier.

On this page