# Linux – SSH session hangs when trying to open a shell

bashlinuxshellssh

Since this morning I cannot login normally on my server using SSH anymore.

Typically, when typing this:

ssh foo@bar.org


The shell hangs and does not acquire shell. The last line of verbose with -vv gives me:

debug2: shell request accepted on channel 0


That said, if I launch a command directly in SSH, such as:

ssh foo@bar.org 'ls ~'


…it seems to work properly and it gives me the expected output. Actually, I can get a shell by forcing bash to launch in interactive mode, by typing:

ssh foo@bar.org 'bash -i'


I also tried to disable my .bashrc file (by moving it to .bashrc_OLD), but it didn't seem to be of any help.

Any suggestion would be much appreciated, thanks!

Edit: I've also tried to login with sh, but it didn't work neither. Thus I believe this is not related to a profile file issue.

Edit 2: when I manage to get a shell using the -i flag, here is the additionnal message I get from the console:

bash: cannot set terminal process group (-1): Invalid argument
bash: no job control in this shell


I think you need to check the remote passwd database (by default /etc/passwd) and see what shell is there (you can then check it via running it directly like you already do with some commands). Other place to look for apart from shell dot files in your home directory is /etc/pam.d and then you should check your remote ~/.ssh directory as well especially if you're using keys to log in.
The terminal issue may mean that bash -i expects a terminal, which can be triggered by ssh -t (it's turned off by default when running a command directly).