[FIXED]Disable login as user

Discussion in 'Linux Beginners' started by Taxick, Oct 8, 2021.

  1. Taxick

    Taxick Member

    Hi :)
    I have two users on my server. User1 and User2. (Root login is disabled)
    User1 has Sudo access - User2 doesn't.
    I want to do so user2 cannot log in with SSH but still can be used on the server to run commands at.
    Im running ubuntu 20.04
    I hope you understand me.
    EDIT: I mean so users don't can login with password on the acc (User2) but only can be accessed by sudo user or root.

    // Thomas
    Last edited: Oct 8, 2021
  2. Taleman

    Taleman Well-Known Member HowtoForge Supporter

    If you only want to prevent logging in with password, that is doable in the SSH server configuration. Set it using only ssh keys to log in and logging in with password is no longer possible. This is then for all users, but logging in with ssh key is more secure anyway.
    If you want to prevent logging in completely for one user, you can deny login user by user.
    Reading man page of sshd for your setup should reveal how these things are done. (I do not know what OS you have so can not help more).
    Jesse Norell likes this.
  3. Taxick

    Taxick Member

    Hi @Taleman
    Thanks for your reply. - After some search, I found some guides that cut help me and now it works.
    I disabled login for USER 2... In the sshd config
    BTW. I'm using ubuntu 20.04
    BTW2 I'm using SSH keys. :)
    Last edited: Oct 8, 2021

Share This Page