設置 | 登錄 | 註冊

目前共有3篇帖子。

在幸狐rv1106板子上本地編譯安裝sudo-1.9.16p2

1樓 巨大八爪鱼 2025-8-5 13:49
工作目錄:
mkdir -p /root/software/sudo
cd /root/software/sudo

請注意一定要設置C_INCLUDE_PATH=/usr/include環境變量,否則編譯會失敗。


【在板子上本地編譯安裝perl-5.40.2】
wget https://www.cpan.org/src/5.0/perl-5.40.2.tar.gz --no-check-certificate
tar xf perl-5.40.2.tar.gz
cd perl-5.40.2
./configure.gnu
make
make install
ldconfig
cd ..

【在板子上本地編譯安裝libxcrypt-4.4.38】
wget https://github.com/besser82/libxcrypt/releases/download/v4.4.38/libxcrypt-4.4.38.tar.xz --no-check-certificate
tar xf libxcrypt-4.4.38.tar.xz
cd libxcrypt-4.4.38
./configure
make
make install
ldconfig
cd ..

【在板子上本地編譯安裝sudo-1.9.16p2】
wget https://www.sudo.ws/dist/sudo-1.9.16p2.tar.gz --no-check-certificate
tar xf sudo-1.9.16p2.tar.gz
cd sudo-1.9.16p2
./configure
執行grep HAVE_CRYPT config.h確認一下HAVE_CRYPT的值是否為1,這個很重要!
make
make install
ldconfig
cd ..

【配置sudo】
解決passwd和su命令無法使用的問題:chmod 4755 /bin/busybox
新建/etc/sudoers.d/oct1158文件(其中oct1158是用戶名):echo "oct1158 ALL=(ALL:ALL) ALL" > /etc/sudoers.d/oct1158
串口裏面只能登錄root賬戶,可以在Windows系統下開一個telnet窗口連接板子,以非root用戶登錄:telnet 板子IP
現在就可以正常在oct1158用戶下使用sudo了,密碼是oct1158用戶的密碼,不是root用戶的密碼。
2樓 巨大八爪鱼 2025-8-5 13:52
編譯sudo-1.9.16p2前必須編譯安裝libxcrypt-4.4.38庫(perl-5.40.2是libxcrypt-4.4.38的依賴項),否則sudo命令只能輸入/etc/passwd裏面的加密後的密碼,輸入linux用戶本身的密碼會提示密碼不正確。
3樓 巨大八爪鱼 2025-8-5 13:56
可以用sudo -V或sudo sudo -V命令查看sudo的版本信息。

luckfox-rv1106 login: oct1158
Password:

Processing /etc/profile... Done

[oct1158@luckfox-rv1106 ~]$ sudo -V
Sudo version 1.9.16p2
Sudoers policy plugin version 1.9.16p2
Sudoers file grammar version 50
Sudoers I/O plugin version 1.9.16p2
Sudoers audit plugin version 1.9.16p2
[oct1158@luckfox-rv1106 ~]$
[oct1158@luckfox-rv1106 ~]$
[oct1158@luckfox-rv1106 ~]$ sudo sudo -V
Password:
Sudo version 1.9.16p2
Configure options:
Sudoers policy plugin version 1.9.16p2
Sudoers file grammar version 50

Sudoers path: /etc/sudoers
Authentication methods: 'passwd'
Syslog facility if syslog is being used for logging: authpriv
Syslog priority to use when user authenticates successfully: notice
Syslog priority to use when user authenticates unsuccessfully: alert
Send mail if the user is not in sudoers
Lecture user the first time they run sudo
Require users to authenticate by default
Root may run sudo
Allow some information gathering to give useful error messages
Visudo will honor the EDITOR environment variable
Set the LOGNAME and USER environment variables
Length at which to wrap log file lines (0 for no wrap): 80
Authentication timestamp timeout: 5.0 minutes
Password prompt timeout: 5.0 minutes
Number of tries to enter a password: 3
Umask to use or 0777 to use user's: 022
Path to mail program: /usr/sbin/sendmail
Flags for mail program: -t
Address to send mail to: root
Subject line for mail messages: *** SECURITY information for %h ***
Incorrect password message: Sorry, try again.
Path to lecture status dir: /var/db/sudo/lectured
Path to authentication timestamp dir: /var/run/sudo/ts
Default password prompt: Password:
Default user to run commands as: root
Value to override user's $PATH with: /usr/local/sbin:/usr/local/bin:/usr/sbin:/u
sr/bin:/sbin:/bin
Path to the editor for use by visudo: /usr/bin/vi
When to require a password for 'list' pseudocommand: any
When to require a password for 'verify' pseudocommand: all
File descriptors >= 3 will be closed before executing a command
Reset the environment to a default set of variables
Environment variables to check for safety:
        TZ
        TERM
        LINGUAS
        LC_*
        LANGUAGE
        LANG
        COLORTERM
Environment variables to remove:
        *=()*
        RUBYOPT
        RUBYLIB
        PYTHONUSERBASE
        PYTHONINSPECT
        PYTHONPATH
        PYTHONHOME
        TMPPREFIX
        ZDOTDIR
        READNULLCMD
        NULLCMD
        FPATH
        PERL5DB
        PERL5OPT
        PERL5LIB
        PERLLIB
        PERLIO_DEBUG
        JAVA_TOOL_OPTIONS
        SHELLOPTS
        BASHOPTS
        GLOBIGNORE
        PS4
        BASH_ENV
        ENV
        TERMCAP
        TERMPATH
        TERMINFO_DIRS
        TERMINFO
        _RLD*
        LD_*
        PATH_LOCALE
        NLSPATH
        HOSTALIASES
        RES_OPTIONS
        LOCALDOMAIN
        CDPATH
        IFS
Environment variables to preserve:
        XDG_CURRENT_DESKTOP
        XAUTHORIZATION
        XAUTHORITY
        PS2
        PS1
        PATH
        LS_COLORS
        KRB5CCNAME
        HOSTNAME
        DISPLAY
        COLORS
Locale to use while parsing sudoers: C
Always run commands in a pseudo-tty
Directory in which to store input/output logs: /var/log/sudo-io
File in which to store the input/output log: %{seq}
Add an entry to the utmp/utmpx file when allocating a pty
PAM service name to use: sudo
PAM service name to use for login shells: sudo
Attempt to establish PAM credentials for the target user
Create a new PAM session for the command to run in
Perform PAM account validation management
Do not allow PAM authentication modules to generate output
Enable sudoers netgroup support
Check parent directories for writability when editing files with sudoedit
Allow commands to be run even if sudo cannot write to the audit log
Allow commands to be run even if sudo cannot write to the log file
Log entries larger than this value will be split into multiple syslog messages:
960
File mode to use for the I/O log files: 0600
Execute commands by file descriptor instead of by path: digest_only
Type of authentication timestamp record: tty
Ignore case when matching user names
Ignore case when matching group names
Log when a command is allowed by sudoers
Log when a command is denied by sudoers
Sudo log server timeout in seconds: 30
Enable SO_KEEPALIVE socket option on the socket connected to the logserver
Verify that the log server's certificate is valid
Set the pam remote user to the user running sudo
The format of logs to produce: sudo
Allow an intercepted command to run set setuid or setgid programs
The largest size core dump file that may be created (in bytes): 0,0
Store plaintext passwords in I/O log input
List of regular expressions to use when matching a password prompt
        [Pp]assword[: ]*
The mechanism used by the intercept and log_subcmds options: trace
Attempt to verify the command and arguments after execution

Local IP address and netmask pairs:
        192.168.4.21/255.255.248.0

Sudoers I/O plugin version 1.9.16p2
Sudoers audit plugin version 1.9.16p2
[oct1158@luckfox-rv1106 ~]$

內容轉換:

回覆帖子
內容:
用戶名: 您目前是匿名發表。
驗證碼:
看不清?換一張
©2010-2025 Purasbar Ver3.0 [手機版] [桌面版]
除非另有聲明,本站採用知識共享署名-相同方式共享 3.0 Unported許可協議進行許可。