从事IT相关工作近10年,获得《网络规划师》《信息系统项目管理师》《系统分析师》、Cisco等认证,对网络和操作系统有较深理解,对认证计费系统和虚拟化技术有深入研究。
分类: LINUX
2013-09-13 13:03:02
Usage: passwd [OPTIONS] [USER]
Change USER's password (default: current user)
-a ALG Encryption method
-d Set password to ''
-l Lock (disable) account
-u Unlock (enable) account
passwd root -d 无论后面任何参数都是去掉用户的密码,完全删除掉密码,这样会导致远程无法访问
|
ID | Method
1 | MD5
2a | Blowfish (not in mainline glibc; added in some | Linux distributions)
5 | SHA-256 (since glibc 2.7)
6 | SHA-512 (since glibc 2.7)
MD5 | 22 characters
SHA-256 | 43 characters
SHA-512 | 86 characters
|
function action_passwd()
local p1 = luci.http.formvalue("pwd1")
local p2 = luci.http.formvalue("pwd2")
local stat = nil
if p1 or p2 then
if p1 == p2 then
stat = luci.sys.user.setpasswd("root", p1)
else
stat = 10
end
end
luci.template.render("admin_system/passwd", {stat=stat})
end
|
--- Retrieve the current user password hash.
-- @param username String containing the username to retrieve the password for
-- @return String containing the hash or nil if no password is set.
-- @return Password database entry
function user.getpasswd(username)
local pwe = nixio.getsp and nixio.getsp(username) or nixio.getpw(username)
local pwh = pwe and (pwe.pwdp or pwe.passwd)
if not pwh or #pwh < 1 or pwh == "!" or pwh == "x" then
return nil, pwe
else
return pwh, pwe
end
end
--- Test whether given string matches the password of a given system user.
-- @param username String containing the Unix user name
-- @param pass String containing the password to compare
-- @return Boolean indicating wheather the passwords are equal
function user.checkpasswd(username, pass)
local pwh, pwe = user.getpasswd(username)
if pwe then
return (pwh == nil or nixio.crypt(pass, pwh) == pwh)
end
return false
end
|
getuser (uid) | Retrieve user informations for given uid. |
checkpasswd (username, pass) | Test whether given string matches the password of a given system user. |
getpasswd (username) | Retrieve the current user password hash. |
setpasswd (username, password) | Change the password of given user. |