You can use AllowUsers / AllowGroups if you have only a few users/groups that are allowed to login via ssh or DenyUsers / DenyGroups if you have only a few users/groups that are not allowed to login. Note that this only restricts login via ssh, other ways of login (console, ftp, …) are still possible. You need to add these options to your /etc/ssh/sshd_config file for most ssh installations.
If you have set the login shell to /bin/false you can use
su -s /bin/bash user (replace /bin/bashwith the shell of your choice)
Look at the shell specified in /etc/passwd for the jenkins user. You can do so by running something like:
grep jenkins /etc/passwd
The output will look similar to this:
The last field is the login shell of the user. Here you can see it is set to /bin/false which will immediately exit.
The solution is to specify which shell to use as you described:
su -s /bin/bash jenkins
Or modify the login shell of the jenkins user with “usermod(8)” (executed as a root user) :
usermod -s /bin/bash jenkins
grep jenkins /etc/passwd should now output something like:
su - jenkins will work as you expect.
You can do it without calling login shell:
sudo DUMMY=dummy su <username> -c 'echo "$DUMMY"'
Generate keys with the command:
ssh-keygen -t rsa
Then add the public key to the authorized_keys with the command:
cat .ssh/new_key.pub >> ~/.ssh/authorized_keys