Remote control when in BusyBox mode

Questions about other topics - please check if your question fits better in another category before posting here
Forum rules
Before you post read how to get help. Topics in this forum are automatically closed 6 months after creation.
Post Reply
User avatar
PRSoftware
Level 2
Level 2
Posts: 67
Joined: Mon Aug 29, 2016 9:42 am
Location: France

Remote control when in BusyBox mode

Post by PRSoftware »

Hello,

This morning, my Linux Mint server was not responding.

After connecting a screen on the graphic card (in normal operation state, it has no screen and I connect on it remotely with SSH), I discovered it had restarted in Busybox mode because of a problem on a filesystem.

I corrected the issue with fsck and restarted the computer which started normally.

My question is: when the computer is in this Busybox mode, is it possible to remotely connect on it (with SSH for example) instead of connecting a physical screen on it (I'm not always present at home and cannot connect a physical screen every time) ?
Linux Mint 21.3 Cinnamon
Desktop (2014) : Materiel.net Arkane : AMD FX-6300 Six-Core / RAM 24 GB / SSD Crucial (2 TB + 1 TB) / GeForce GT 730
Laptop (2011) : eMachines G630 : AMD Athlon II M320 Dual-Core / RAM 4 GB / SSD Crucial (480 GB) / Radeon 4570
User avatar
spamegg
Level 14
Level 14
Posts: 5118
Joined: Mon Oct 28, 2019 2:34 am
Contact:

Re: Remote control when in BusyBox mode

Post by spamegg »

It seems like that is possible, but I don't know how to do it.
Apparently BusyBox has to be recompiled with its minimal SSH server enabled.
Although I'm not sure if this applies to the BusyBox that happens during the boot process or not.
Because the BusyBox during boot failure might be just part of the boot initrd image.
Here's what AI told me (so don't apply this blindly, there might be some better guides out there):
tgpt "On Linux, how to access busybox prompt remotely?" ─╯

To access the BusyBox prompt remotely on a Linux system, you can use SSH (Secure Shell). BusyBox includes a minimal SSH server that can be used for this purpose. Here's a step-by-step guide on how to set it up and access it remotely:

### 1. Install BusyBox
First, ensure that BusyBox is installed on your Linux system. If it's not installed, you can install it using your distribution's package manager. For example, on Debian-based systems, you can use:

Code: Select all

sudo apt-get update
sudo apt-get install busybox
### 2. Enable SSH Server in BusyBox
BusyBox includes a minimal SSH server that can be enabled by editing the BusyBox configuration file. You need to recompile BusyBox with the SSH server enabled.
1. **Download the BusyBox source code** from the official website or use your distribution's package source.
2. **Extract the source code** and navigate to the directory.
3. **Configure BusyBox** with the SSH server enabled. You can do this by running:

Code: Select all

make menuconfig
In the menu, navigate to Networking utilities and ensure dropbear (a lightweight SSH server) is selected.
4. **Compile and install** BusyBox with the new configuration:

Code: Select all

make
sudo make install
### 3. Configure Dropbear SSH Server
After installing BusyBox with the SSH server enabled, you need to configure the Dropbear SSH server.
1. **Create a configuration file** for Dropbear. You can use the dropbearkey utility to generate a host key:

Code: Select all

dropbearkey -t rsa -f /etc/dropbear/dropbear_rsa_host_key
2. **Create a configuration directory** for Dropbear if it doesn't exis:

Code: Select all

sudo mkdir -p /etc/dropbear
3. **Create a Dropbear configuration file**. You can use a text editor to create /etc/dropbear/dropbear.conf and add the following lines:

Code: Select all

NO_START=1
DROPBEAR_PORT=2
DROPBEAR_EXTRA_ARGS="-s -j -k"
This configuration sets the default port to 2, enables strict mode, and disables password authentication.

### 4. Start the Dropbear SSH Server
You can start the Dropbear SSH server manually or set it to start automatically at boot.
- **Manually start** the server:

Code: Select all

sudo dropbear
- **To start automatically**, you can add the command to your system's startup scripts, such as /etc/rc.local or create a systemd service.

### 5. Access the BusyBox Prompt Remotely
Now that the SSH server is running, you can access the BusyBox prompt remotely using an SSH client. From another machine, use the following command:

Code: Select all

ssh root@your_server_ip
Replace your_server_ip with the IP address of your Linux system. You'll be prompted for the root password.

### Note
- Ensure that your firewall allows SSH connections on the port you've configured (default is 2).
- For security reasons, it's recommended to use key-based authentication instead of passwords.
- Always ensure that your system is secure and that you're following best practices for SSH and network security.
Post Reply

Return to “Other topics”