Issue
I wanted to create a new user on my linux server so that he can access my postgres database through an ssh tunnel. However, I want him to restrict his access only to the ssh tunnel.
- login on server as
root
- Create a new user with
useradd new_user -M -s /bin/true
- Set a password with
passwd new_user
- make sure that
PasswordAuthentication yes
is set and uncomment in/etc/ssh/sshd_config
- Restart ssh with
sudo systemctl reload sshd
- Logout from server and login to server with new user with
ssh -p 7822 new_user@my_address.com -N 5433:localhost:5432
(I am using a2hosting as a provider, where I need to use port 7822 for ssh)
However, when I try to login I get the error
Permission denied, please try again.
When I do everything like above but change step 2 into
useradd new_user -m -d /home/new_user
I can successfully login with the new user, however, I then have the possibility to actually access command line, which I try to avoid. What am I doing wrong here?
Solution
It could be that /bin/true is not available on the system. As an alternative, use the alternate /bin/false.
Both perform the same function but /bin/false tends to be used more.
Answered By - Raman Sailopal Answer Checked By - David Marino (WPSolving Volunteer)