Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

If I log in to a system over ssh, I can use the default shell with a simple ssh user@host, or specify something like ssh user@host 'bash --norc --noprofile' or ssh user@host ksh.

Is it possible to have similar behaviour when logging in on a local terminal, ie one where my terminal is connected directly to the system and I'm prompted for a username?

The specific usage scenario is running screen at login time, where a duff config option will prevent screen starting, and thus prevent the login succeeding. If I have ssh access, I can log in and run specific commands to fix things, but if I only have terminal access, I can't see how I could fix things up.

share|improve this question
add comment

3 Answers 3

You could copy the entry for user in /etc/passwd and change (a) the name from user to e.g. user_mod_shell, and (b) the default shell. The "who am i" chaos (probably without real problems) may be reduced by setting USER in the start processes.

share|improve this answer
    
I don't follow. So the result here would be two users, one for normal use, and one that solely exists for clearing up a login mess that the first had gotten itself into? –  me_and May 17 '13 at 13:02
1  
@me_and No you would have several names for the same user, one name for each shell. For each user name a different shell would be started. –  Hauke Laging May 17 '13 at 13:33
    
exactly - also mentioned here: unix.stackexchange.com/questions/74961/… –  peterph May 17 '13 at 14:17
    
Multiple entries with the same UID, then? Cunning! –  me_and May 22 '13 at 20:17
add comment

Put your terminal multiplexer (be it tmux, screen or something else) into your shell's initialization, but do not exec it (which one would probably do) - that will jump back into shell if anything goes wrong in the terminal multiplexer.

To make it more user friendly, you can use the suggestion from comment by @EvanTeitelman and actually run multiplexer && exit, which will quit the session if the multiplexer exits normally.

share|improve this answer
    
Nice idea, but I'd prefer to avoid giving the user two shells to break out of in the normal use case. –  me_and May 17 '13 at 13:01
1  
You could do this: screen && exit. That way, if screen runs sucessfully, the shell will exit. –  paraxor May 17 '13 at 13:19
add comment

Eventually, we went with having the .bash_profile run screen if and only if the variable $SSH_CONNECTION was set. That means the normal use case (logging in via ssh) gets screen (and we can work around that by specifying bash --noprofile as the command to run on login), and for console connections we just get a regular session.

Of course, if we hose things somehow such that screen is executed on every login, we're still hosed. But there's no way of making this utterly foolproof.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.