An account with /usr/sbin/nologin as its shell is permitted to set establish port forwarding. However, if you attempt to run a shell command, the connection is forcibly terminated. The fix is to not run a shell command:. With OpenSSH (the SSH implementation on almost all non-embedded Unix/Linux systems), pass the option -N to the SSH client. I don't know the PuTTY equivalent.
ssh -N -L 1234:somehost:5678 [email protected] With PuTTY, tick “Don't start a shell or command at all” in the Connection > SSH tab.