0

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.

I followed these steps:

  1. login on server as root
  2. Create a new user with useradd new_user -M -s /bin/true
  3. Set a password with passwd new_user
  4. make sure that PasswordAuthentication yes is set and uncomment in /etc/ssh/sshd_config
  5. Restart ssh with sudo systemctl reload sshd
  6. 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?

0
Match user foo
    ForceCommand echo 'Only TCP port forwarding to PostgreSQL enabled!'
    PermitOpen 127.0.0.1:5432
    PermitUserRC no
    PermitTTY no

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.