openwrt系统默认的用户名是root,而且web页登陆页面也默认是填充用户名root的状态,因此在考虑到安全性以及本身的个性,因此须要本身制定本身喜欢的用户名和密码。html
1、修改密码node
一、在openwrt开发板上密码web
使用指令 passwd,直接输入密码便可完成密码重置。安全
二、修改源码实现实现密码的永久指定bash
如今开发板上使用指令 passwd 修改密码,而后将 /etc/shadow 文件里面的内容拷贝到源码文件app
里面,而后make V=99编译便可。工具
2、在openwrt开发板上修改用户名,将 root 修改为本身想要的名称(此处以name为例)。lua
一、/etc/passwdspa
将code
1 root:x:0:0:root:/root:/bin/ash
修改为
1 name:x:0:0:root:/root:/bin/ash
二、/etc/shadow
将
1 root:$1$CUZfPWNP$jl8w3/uwU/qtjjBfa.urF/:18216:0:99999:7:::
修改为
将
1 page.title = _("Administration") 2 page.order = 10 3 page.sysauth = "root" 4 page.sysauth_authenticator = "htmlauth" 5 page.ucidata = true 6 page.index = true 7 page.target = firstnode()
修改为
1 page.title = _("Administration") 2 page.order = 10 3 page.sysauth = "name" 4 page.sysauth_authenticator = "htmlauth" 5 page.ucidata = true 6 page.index = true 7 page.target = firstnode()
四、/etc/config/rpcd
将
1 option username 'root' 2 option password '$p$root'
修改为
1 option username 'name' 2 option password '$p$name'
至此,简单的用户名修改已经完成修改。若是须要 web登陆页面不自动填写用户名,那么只须要修改:
五、/usr/lib/lua/luci/view/sysauth.htm
将
1 <input class="cbi-input-text" type="text" name="luci_username" value="<%=duser%" />
修改为
1 <input class="cbi-input-text" type="text" name="luci_username" value="" />
3、在开发环境源码中修改用户名(下面的步骤与上面在开发板上修改的步骤一一对应)
1、./openwrt/package/base-files/files/etc/passwd 2、./openwrt/package/base-files/files/etc/shadow 3、./openwrt/feeds/luci/modules/luci-base/luasrc/controller/admin/index.lua 4、./openwrt/package/system/rpcd/files/rpcd.config 5、./openwrt/feeds/luci/modules/luci-base/luasrc/view/sysauth.htm
这样,在编译完成以后烧写到开发板上,仍是修改后的名称,在网页端显示的也是。完成修改。
4、修改openwrt的主机名(以username为例)
一、在开发板上修改
将 /etc/config/system 中的
1 option hostname OpenWrt 2 option timezone UTC
修改为
1 option hostname username 2 option timezone UTC
而后 reboot 重启便可。
二、在开发源码中修改文件
./openwrt/package/base-files/files/etc/config/system
修改方式与上面相同。
5、经过串口工具进入openwrt终端须要用户名和密码
一、在开发板上修改
将文件 /usr/libexec/login
1 #!/bin/sh 2 [ "$(uci -q get system.@system[0].ttylogin)" = 1 ] || exec /bin/ash --login 3 exec /bin/login
修改为
1 #!/bin/sh 2 [ "$(uci -q get system.@system[0].ttylogin)" = 1 ] || exec /bin/login 3 exec /bin/login
二、在编译源码中修改文件
./package/base-files/files/usr/libexec/login.sh
修改方式与上述相同。