Redmi AC2100 路由器 官方固件允许IPv6外网访问下游设备
红米 AC2100 开启远程 SSH
- 升级/降级 至 官方固件版本: 2.0.23 稳定版。操作入口在路由器常用设置-系统状态-升级检测处。
- 开启SSH权限。F12打开浏览器的开发者模式,并切换至终端选项卡,复制以下代码至终端处,并敲回车执行:
登录路由器Web 页面,在 Web 页面打开 F12 开发者模式,在 console 中输入:
java
function getSTOK() {
let match = location.href.match(/;stok=(.*?)\//);
if (!match) {
return null;
}
return match[1];
}
function execute(stok, command) {
command = encodeURIComponent(command);
let path = `/cgi-bin/luci/;stok=${stok}/api/misystem/set_config_iotdev?bssid=SteelyWing&user_id=SteelyWing&ssid=-h%0A${command}%0A`;
console.log(path);
return fetch(new Request(location.origin + path));
}
function enableSSH() {
stok = getSTOK();
if (!stok) {
console.error('stok not found in URL');
return;
}
console.log(`stok = "${stok}"`);
password = prompt('Input new SSH password');
if (!password) {
console.error('You must input password');
return;
}
execute(stok,
`
nvram set ssh_en=1
nvram commit
sed -i 's/channel=.*/channel=\\"debug\\"/g' /etc/init.d/dropbear
/etc/init.d/dropbear start
`
)
.then((response) => response.text())
.then((text) => console.log(text));
console.log('New SSH password: ' + password);
execute(stok, `echo -e "${password}\\n${password}" | passwd root`)
.then((response) => response.text())
.then((text) => console.log(text));
}
enableSSH();
此时会弹出一个对话框,要求输入密码,请输入并记住这个密码,敲回车提交。 4. 使用Putty 或 Xshell 终端连接路由器,MIWIFI默认网关地址为 192.168.31.1,用户名为 root,密码为上一步设定的密码。