I'm running OpenBSD 5.7 on VirtualBox on my Windows 7, to learn more about Unix, but I can't use sudo with my password. I've set up a user called adminvpn but when I try to run any command using sudo it tells that my password is wrong!

I have already tried my root password and my user password and I'm 100% sure they are correct and they are only letters... I have reinstalled OpenBSD 3 times and this is driving me crazy.

When I try to use my password for "adminvpn" I get

adminvpn is not in the sudoers file. This incident will be reported.

I'm able to log in with root and using my root password. I'm almost giving up to running it with a user.

  • 1
    Persist, it gets easier: There is a bit of a learning curve. You can choose to pretend the command line does not exist, then Unix is like MS-Windows, but a bit more consistent, and not prone to mood swings. Or you can learn the command line, as you do you will slowly become more powerful, eventually you will be able to do anything. Jun 14, 2015 at 22:08
  • 2
    fyi, nowadays OpenBSD use man.openbsd.org/doas.1 and not sudo. The original documentation for a website should be always better than an outdated forum question. sudo is irrelevant on OpenBSD now.
    – Hessnov
    Feb 28, 2018 at 7:33

2 Answers 2


The error message tells you what is wrong even if it doesn't tell you exactly how to fix it.

adminvpn is not in the sudoers file.

sudo lets you run commands as the administrator. In order to be able to use sudo, you need to be made an administrator. Accounts are not made administrators by default.

Run the command visudo (as root, of course) and add a line like the following:

adminvpn ALL=(ALL) ALL

Save the file and exit. You can now run any command as root with sudo.

Note that visudo will run your favorite editor, as indicated by the environment variable VISUAL. If you haven't configured that, you'll get vi. If you're uncomfortable with vi, install another editor (e.g. pkg_add nano) and add a line like export VISUAL=nano to ~/.profile; run the command in your interactive shell as well for it to take effect in the current session.

Unless configured otherwise, sudo requires you to type your own password. Knowledge of the root password is not necessary, that's the point of sudo. The point of typing your password is to make sure it isn't someone else typing while you left your keyboard unattended.

By the way, OpenBSD isn't the most beginner-friendly Unix out there. If you want a gentler learning curve, try Ubuntu.

  • 1
    You will note that /etc/sudoers probably has the entry %sudo ALL=(ALL:ALL) ALL. If so then you only need add a user to group sudo, no need to edit /etc/sudoers. Jun 14, 2015 at 21:57
  • To run visudo using nano (without pre-config in ~/.profile): first install nano, then EDITOR=nano visudo. Jun 14, 2015 at 22:02
  • @richard Is that %sudo line present on OpenBSD these days? It isn't on my admittedly old VM with OpenBSD 4.8, sudo 1.7.2. If it is, then @Freedom, you can add yourself to the sudo group by running usermod -G sudo adminvpn, then logging out and back in. Jun 14, 2015 at 22:22
  • I have no idea, it does on Debian 6, but don't know about OpenBSD. That is why I used a conditional clause in the comment. I also put it for other Unixers that way pass this way. Jun 14, 2015 at 22:25
  • 2
    "If you want a gentler learning curve, try Ubuntu." Or even FreeBSD. OpenBSD is probably the least newbie-friendly *nix available to commoners. FreeBSD still won't do much in terms of holding your hand and walk you through the basics, but at least a default installation is reasonably usable out of the box (ISO?). Also, I consider the FreeBSD documentation to be exemplary.
    – user
    Jun 22, 2016 at 19:55

OpenBSD 5.8 or later comes with doas instead of sudo (which remains available as a package), and by default it's not configured to let you run things.

Create file /etc/doas.conf and add to it:

permit persist adminvpn as root
permit persist keepenv root as root

The first line lets adminvpn do as root. The seconds one lets root do as root. While it looks silly, it's for the convenience of being able to run commands with the doas "prefix" both as adminvpn and root. Without it you'd need to run the plain command if you're already logged in as root.

If you need to let adminvpn run commands as different users, you can add additional permit lines to the file.

Then you can do:

doas my-privileged-command

to run my-privileged-command as root.

Thanks to Kusalananda for the helpful comment.

  • 2
    Note that doas was introduced in OpenBSD 5.8, and that the question is about sudo on OpenBSD 5.7. The issue is not about doas but with correct configuration of sudo. Also note that OpenBSD still has sudo as a package.
    – Kusalananda
    Apr 16, 2019 at 9:31
  • 1
    This worked for me perfectly, thanks!
    – james-see
    Feb 17, 2020 at 19:49

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .