How I Work Fully Remote through SSH without Sudo Rights
Tags: terminal, ssh, python, vim
Published: 2024-03-09 18:24:24

The pinnacle of my dream setup wishlist was a fully functional terminal workflow.

Throughout my academic journey, I dabbled with various Linux distributions, investing countless hours into configuring my tiling window manager and experimenting with suckless software. Although enjoyable, it wasn't particularly productive. Post-graduation, with the pressing need for efficiency, I reluctantly transitioned to an Ubuntu workstation — a tough but necessary adjustment.

Yet, the allure of a terminal-only setup remained.

I eventually discovered a method to tick all the boxes for a terminal-only setup, giving me compelling reasons to pursue this path. Primarily, it allowed for a fully remote development setup on the same system where my projects would be deployed. Whether it's executing torch code on a cluster entry node or deploying services in a Docker container, this approach proved invaluable.

The constraints imposed on the remote machines were strict:

- No sudo rights
- No option to install my preferred development software
- No GUI
- Restricted internet access behind a firewall

Moreover, I sought a development setup that could be ready in under an hour without any configuration requirements.

Even if you opt not to adopt this method fully, having such a system partially ready for on-the-fly production system edits could be beneficial.

Here's a rundown of my software stack:

- junest
- AstroNvim + LSP setup
- nnn
- Tmux
- htop ...

Besides a stable internet connection, a proxy for mostly unrestricted internet access is essential. While not mandatory, Git is assumed to be a ubiquitous resource on most server Linux installations.

I'll detail each component below. Feel free to tailor anything to your needs.

### Junest

This project was a game-changer, enabling my full terminal transition earlier than expected.

At its core, Junest is an Arch Linux subsystem that leverages the pacman package manager for installations, encompassing AUR repositories to meet the demands of Linux power users.

Explore the [Junest Git project](https://github.com/fsquillace/junest) and follow the installation instructions. Activate the environment with `junest setup` and enable the running-from-host options.

That's all!

You can now install virtually anything with:

```bash
sudoj pacman -S <package>
```

For example, to install the software listed above:

```bash
sudoj pacman -S neovim nnn tmux htop
```

### AstroNvim with LSP Setup

My Python development needs are straightforward:

- Quick file navigation
- Proper completion and search by symbols
- Basic debugging
- Minimal configuration with immediate functionality
- Vim bindings

AstroNvim could be your entry point into a terminal editor that incorporates essential VSCode functionalities, especially if you're accustomed to Vim bindings.

Previously a PyCharm and VSCode user, I switched to Nvim after discovering AstroNvim, a pre-configured Nvim installation ready to use.

For Python debugging, follow the easy two-step installation process detailed on the [AstroNvim website](https://astronvim.com/).

For a similar Python setup to mine, refer to my [simple user configuration](https://github.com/freiberg-roman/astro-config), which includes installation instructions.

Alternatively, Emacs is worth exploring for those not satisfied with Vim, though I haven't used it myself. For minimal editing, Nano may suffice.

### NNN

This CLI file manager, compatible with Vim bindings, facilitates rapid directory browsing. Press `?` within the program to access the manual.

NNN's learning curve is surprisingly gentle, even for non-Vim users.

### Tmux

This widely used terminal multiplexer is invaluable, especially in server environments lacking a job scheduler. It ensures ssh sessions persist after disconnection.

For common workflows, consult this handy [tmux cheat sheet](https://tmuxcheatsheet.com/).

To start and connect to a new session:

```bash
tmux new -s <mysession>
tmux at -t <mysession>
```

Disconnect without closing using Ctrl-b.

### Final Thoughts

While there's much more to explore, these tools likely cover the majority of command-line software used in my daily development routine.

I still rely on GUI software, including web browsers. The primary motivation behind this development setup is to bridge the gap between my development and production environments, facilitating immediate debugging when necessary.

Compared to my idealistic setup during my studies, this system has significantly boosted my productivity, even under the constraints often imposed by corporate environments including custom hardware and non-existent Linux `sudo` rights.