openwrt配置 -- 修改用户名、密码以及网页用户名的修改

openwrt系统默认的用户名是root,并且web页登录页面也默认是填充用户名root的状态,所以在考虑到安全性以及自己的个性,所以需要自己制定自己喜欢的用户名和密码。

一、修改密码

1、在openwrt开发板上密码

使用指令 passwd,直接输入密码即可完成密码重置。

2、修改源码实现实现密码的永久指定

现在开发板上使用指令 passwd 修改密码,然后将 /etc/shadow 文件里面的内容拷贝到源码文件

/openwrt/package/base-files/files/etc/shadow

里面,然后make V=99编译即可。

 二、在openwrt开发板上修改用户名,将 root 修改成自己想要的名称(此处以name为例)。

1、/etc/passwd

1 root:x:0:0:root:/root:/bin/ash

修改成

1 name:x:0:0:root:/root:/bin/ash

2、/etc/shadow

1 root:$1$CUZfPWNP$jl8w3/uwU/qtjjBfa.urF/:18216:0:99999:7:::

修改成

1 name:$1$CUZfPWNP$jl8w3/uwU/qtjjBfa.urF/:18216:0:99999:7:::

3、/usr/lib/lua/luci/controller/admin/index.lua

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()

4、/etc/config/rpcd

1     option username 'root'
2     option password '$p$root'

修改成

1     option username 'name'
2     option password '$p$name'

至此,简单的用户名修改已经完成修改。如果需要 web登录页面不自动填写用户名,那么只需要修改:

5、/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="" />

三、在开发环境源码中修改用户名(下面的步骤与上面在开发板上修改的步骤一一对应)

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

这样,在编译完成之后烧写到开发板上,还是修改后的名称,在网页端显示的也是。完成修改。

四、修改openwrt的主机名(以username为例)

1、在开发板上修改

/etc/config/system 中的

1 option hostname OpenWrt
2 option timezone    UTC

修改成 

1 option hostname username
2 option timezone    UTC

然后 reboot 重启即可。

 2、在开发源码中修改文件

        ./openwrt/package/base-files/files/etc/config/system

 修改方式与上面相同。

五、通过串口工具进入openwrt终端需要用户名和密码

1、在开发板上修改

将文件 /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

2、在编译源码中修改文件

        ./package/base-files/files/usr/libexec/login.sh

修改方式与上述相同。

猜你喜欢

转载自www.cnblogs.com/songshuaiStudy/p/12194321.html