# cd /usr/ports/security/doas/
# make install clean
查看安装后信息
root@ykla:~ # pkg info -D doas
doas-6.3p12:
On install:
To use doas,
/usr/local/etc/doas.conf
must be created. Refer to doas.conf(5) for further details and/or follow
/usr/local/etc/doas.conf.sample as an example.
# 要使用 doas,必须创建配置文件 /usr/local/etc/doas.conf。
# 可参考 doas.conf(5) 的联机文档,或查看 /usr/local/etc/doas.conf.sample 示例配置。
Note: In order to be able to run most desktop (GUI) applications, the user
needs to have the keepenv keyword specified. If keepenv is not specified then
key elements, like the user's $HOME variable, will be reset and cause the GUI
application to crash.
# 注意:如果需要运行图形界面(GUI)程序,配置中必须添加 keepenv 关键词。
# 否则像 $HOME 这样的环境变量将会被清空,导致 GUI 程序崩溃。
Users who only need to run command line applications can usually get away
without keepenv.
# 如果只需要运行命令行程序,通常不需要 keepenv。
When in doubt, try to avoid using keepenv as it is less secure to have
environment variables passed to privileged users.
# 如果不确定是否需要,建议尽量避免使用 keepenv,因为它可能降低系统安全性,
# 会将原用户的环境变量传递给拥有权限的目标用户。
On upgrade from doas<6.1:
With the 6.1 release the transfer of most environment variables (e.g. USER,
HOME and PATH) from the original user to the target user has changed.
# 从 doas 6.1 版本起,环境变量(如 USER、HOME、PATH)传递方式已发生变化。
Please refer to doas.conf(5) for further details.
# 请查看 doas.conf(5) 联机文档以了解更多详情。
# Sample file for doas
# Please see doas.conf manual page for information on setting
# up a doas.conf file.
# Permit members of the wheel group to perform actions as root.
permit :wheel # 允许 wheel 组成员 doas
# Same without having to enter the password
permit nopass :wheel # 允许 wheel 组成员 doas,但免密码
# Permit user alice to run commands as a root user.
permit alice as root # 允许用户 alice doas
# Permit user bob to run programs as root, maintaining
# environment variables. Useful for GUI applications.
permit keepenv bob as root # 允许用户 bob doas,并继承用户 bob 的环境变量,GUI 程序需要,但会降低安全性(参见查看安装后信息)
# Permit user cindy to run only the pkg package manager as root
# to perform package updates and upgrades.
permit cindy as root cmd pkg args update # 仅允许用户 cindy 执行 pkg update
permit cindy as root cmd pkg args upgrade # 仅允许用户 cindy 执行 pkg upgrade
# Allow david to run id command as root without logging it
permit nolog david as root cmd id # 允许 David 以 root 身份运行 `id` 命令且不记录日志
对于一般人只需要创建文件 /usr/local/etc/doas.conf,写入
permit :wheel
即可满足日常需求(你的用户须加入 wheel 组)。
sudo
安装
FreeBSD 基本系统默认不自带 sudo 命令,需要使用 root 权限自行安装:
# pkg install sudo
或者:
# cd /usr/ports/security/sudo/
# make install clean