Netgate Discussion Forum
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Search
    • Register
    • Login

    Allow only ssh login for admin

    Scheduled Pinned Locked Moved General pfSense Questions
    6 Posts 4 Posters 371 Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • CatSpecial202C
      CatSpecial202
      last edited by

      When you login to the admin user via ssh you end up in the root user, correct? Is it possible to enable SSH login via public key for the admin user?

      patient0P GertjanG 2 Replies Last reply Reply Quote 0
      • patient0P
        patient0 @CatSpecial202
        last edited by

        @CatSpecial202 have a look at the documentation:

        https://docs.netgate.com/pfsense/en/latest/recipes/ssh-access.html#ssh-keys

        "When the SSH daemon is set for key-based authentication, it uses the keys defined on user accounts. Add keys to individual user accounts under System > User Manager. The admin user and root user share keys."

        1 Reply Last reply Reply Quote 0
        • stephenw10S
          stephenw10 Netgate Administrator
          last edited by

          You can set ssh to key based only but not set that per user. Unless I missed a change at some point. 😉

          CatSpecial202C 1 Reply Last reply Reply Quote 0
          • CatSpecial202C
            CatSpecial202 @stephenw10
            last edited by CatSpecial202

            @stephenw10 So, just don't provide an SSH key to the users. Only provide the admin/root account with an ssh key. Then grant only public key auth.

            I was thinking something like disabling the admin user from logging into the system like clicking the option below, but granting some permission somewhere that would allow the admin to only login via key based auth via ssh? I want to disable GUI login for the admin and allow only SSH login. Is that possible?

            9d51afad-3561-427a-a314-bf95b60b896e-image.png

            1 Reply Last reply Reply Quote 0
            • stephenw10S
              stephenw10 Netgate Administrator
              last edited by

              Not as far as I know.

              If you disable login there it will disable SSH login too.

              What you can't do with SSH is force admin to use a key whilst allowing some other user to login with a password. The option to set the login type applies to all users.

              1 Reply Last reply Reply Quote 0
              • GertjanG
                Gertjan @CatSpecial202
                last edited by

                @CatSpecial202 said in Allow only ssh login for admin:

                Is it possible to enable SSH login via public key for the admin user?

                Not only possible. Its imho pretty mandatory.

                Any every server device you use, rent, buy create, uses initially a SSH connection, and the admin (mostly root) + password is send to you.
                Or you created these when installing the OS.

                Os soon as you enter the first time, you create cert. Export the public part to yoruself, so you can use it with your SSH client, for example Putty.

                The 'admin' user on pfSense should have this part :

                f6007dfb-5168-45c3-94ac-6a40cb5ad49d-image.png

                and then you select (again : pfSense) :

                7afdc234-f7df-4035-8ef6-381c4dc4708e-image.png

                and from now on, your SSH client will be needing the exported cert to be able to connect to pfSense :

                69e4ee4d-b341-4809-a487-237a2f376f0a-image.png

                and I have to type in the password == passphrase of the cert, not the admin password.

                Do this with pfSense, and any other device you can connect to over SSH - if possible.

                edit : don't even bother grating other users access to pfSense with non admin accounts.
                pfSense is a router, not some multi media file server.
                I always recommend severely creating an ssh admin pfSense so you can have access, when needed.
                Some will then never really use it afterwards.
                Other - like me - use it several times a day. As I use the same connection with for example WinSCP, so I can explore the file system, and look at things like using Windows explorer. Don't ask me why ^^

                If needed, block the SSH port TCP 22 to some known LAN IPs.
                Lock your own devices, the ones you can use to connect to pfSense, with a DHCP MAC lease, so from now on they will always have the same IP.
                Throws these IPs in a Alias.*Use this Alias to create a LAN firewall rule.
                From now on, only these IPs can use the pfSense SSH port.

                Read security nerds will use a dedicates admin LAN, and connect to this LAN with their device to access pfSense SSH.
                Now lock your pfSense into a safe. Lock the safe. Done. Now you're close to what they use at Langley.

                No "help me" PM's please. Use the forum, the community will thank you.
                Edit : and where are the logs ??

                1 Reply Last reply Reply Quote 0
                • First post
                  Last post
                Copyright 2025 Rubicon Communications LLC (Netgate). All rights reserved.