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

修改方式與上述相同。


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM