1

I am running Ubuntu Server 20.04 headlessly, and typically remote into it via SSH. However, it is also connected via serial RS232 to a terminal server (a Digi CM 16) for kernel console logging and as a backup management method.

Here's the thing: I use ZSH with some ultra-fancy add-ons. Works great over SSH. Serial, not so much. The logfiles from the terminal server are usually not very coherent due to all the control characters ZSH is throwing around.

How do I force the serial console login to use BASH, even though my user's default shell is ZSH?

Here's what I want:

Method of logging in Shell I want to be presented with
SSH ZSH (user default)
Serial Console login BASH
Plug in monitor and keyboard and physically login don't care

I've tried looking at changing the getty settings for ttyS0, and it appears that the only option is to change the default login executable from /bin/login, but I don't think I want to do that? Still want to login with a password, just want to change the shell spawned after logging in just if logging in from ttyS0

1 Answer 1

1

Probably the easiest way is to add code in ~/.zprofile to detect if you are on the serial line and then take some action.

You could exec bash from there, but alternately, you could disable noisy zsh extensions and reset the prompt to something simple and still use zsh.

Note however, that while you are playing with this, you should keep a second shell open (or have a back door account) in case you corrupt something that prevents your account from getting any shell.

2
  • Thanks! I had thought of the detect-then-exec-bash, and I may end up doing this eventually, but I would rather not have ZSH start at all if logging in from the serial line. I feel like there has to be a way to accomplish this, but maybe not? Also, I hadn't thought of just not loading ZPrezto if serial detected. That could be another option as well.
    – staehle
    Jul 30, 2021 at 17:12
  • 1
    I think zsh is probably no worse than bash if you strip it down. It would probably be more efficient to conditionally not load extra extensions than to exec a second shell in the middle of initializing the first shell. Another alternative is to create a minimal third shell (small compiled binary) that picks one of the other two, but that just seems overly complex.
    – user10489
    Jul 31, 2021 at 1:50

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .