Strovent SystemsSign in
Reference

SSH "This account is currently not available" (nologin shell)

SSH logs in, prints This account is currently not available, then closes. The account's login shell is nologin. How to check it, change it, or use ssh -N.

Authentication worked, so the user name, password or key are fine. The host then started the account's login shell, and that shell is nologin. It prints the message and exits, so the session closes straight away.

This account is currently not available.
Connection to host.example.com closed.

Why an account has nologin

nologin is meant to be put in the shell field of an account that should never get an interactive login, such as a service account (www-data, ftp) or an account made only for port forwarding or file transfer. It always refuses the login, and it shows the contents of /etc/nologin.txt instead of its default message if that file exists.

So this is usually a setting, not a fault. Ask whether the account is supposed to have a shell before changing it.

Similar symptoms

  • The session closes with no message. The shell is probably /bin/false, which exits silently.
  • A notice from the administrator, then a disconnect, for every user except root. That is not the account's shell. The file /etc/nologin (or /var/run/nologin) exists, and while it does, sshd and the pam_nologin module refuse every login except root and show the file's text.

Check the shell

On the host, as any user who can log in:

getent passwd user1

The last field of the line is the login shell, for example user1:x:1001:1001::/home/user1:/usr/sbin/nologin.

Give the account a shell

An administrator can change it with sudo usermod -s /bin/bash user1. The user can also run chsh -s /bin/bash if the system allows it. chsh -l lists the shells in /etc/shells.

If the account is meant for forwarding only

Do not ask for a shell at all. ssh -N opens the connection without running a remote command, which is what a forwarding-only account expects:

ssh -N -L 8080:localhost:80 [email protected]

SFTP and nologin

sshd starts every command and subsystem through the account's login shell (shell -c command). An external SFTP server set with Subsystem sftp /usr/lib/openssh/sftp-server is therefore blocked by nologin too. The internal-sftp server runs inside sshd, so a host can give file transfer to a nologin account by setting Subsystem sftp internal-sftp or ForceCommand internal-sftp for that account.

Sources

Spotted a mistake? Email [email protected].