Direct-SSH is a lightweight script that runs when a USB drive is connected with a single file called DIRECT.SSH. The script will then change the Netplan settings, so that the Raspberry Pi is assigned the static IP address 192.168.0.50 on eth0. When the USB drive is disconnected, the netplan is automatically reverted to its original configuration.
The script can come in handy if you are in a networkless environment but still need to SSH into your Raspberry Pi.
- Raspberry Pi running Ubuntu Server 22.04.3 LTS or similar
- Internet access for initial setup
- GitHub CLI (
gh) installed
Install Rbrito's usbmount:
apt-get install -y debhelper build-essential
gh repo clone rbrito/usbmount
cd usbmount
dpkg-buildpackage -us -uc -b
sudo dpkg -i ../usbmount_*.deb
rm ../usbmount_* # Clean up build files
cd ../direct-sshFor further instructions visit Rbrito`s Repo
Automated installation of systemd service:
sudo python3 setup.py- Create an empty file called
DIRECT.SSHon a USB thumbdrive. The file should be the only file on that USB drive. - Plug the USB drive into the Raspberry Pi
- After a few seconds the netplan will be reconfigured to set the static IP address
192.168.0.50on the interfaceeth0 - Connect your Raspberry Pi directly to your computer using an Ethernet cable
- Open a console and SSH into your Raspberry Pi using the IP address
192.168.0.50 - You now have a direct SSH connection established.
- Disconnect the USB drive that contains the file
DIRECT.SSH - The script will automatically revert the Netplan configuration to its original state.
Direct-SSH has been tested in the following environments. Compatibility with other hardware or operating systems has not yet been verified.
- Raspberry Pi 3B running Ubuntu server 22.04.3 LTS
- Raspberry Pi 4B running Ubuntu server 22.04.3 LTS
- Raspberry Pi 5B running Ubuntu server 22.04.3 LTS
This project is licensed under the GNU General Public License v3.0. See the LICENSE file for details.