很久以前就在JD弄了一个K2,当时没有啥需求,所以也没有折腾 。最近尝试DDNS域名绑定到动态的IP,想在家有一个能提供SSH访问的机器。原来的树莓派被弄坏了,就想着折腾折腾刷刷K2,在上面安装一个SSH。
同时也把官网提供的系统净化净化。
原K2的详细信息
斐讯K2 1200M智能双频无线路由器 WIFI穿墙 PSG1218
了解刷机流程
http://www.right.com.cn/forum/thread-208302-1-1.html
【2017-12-01】斐讯K2 V22.5.9.163官方固件定制版,集成breed,支持官版直刷【V1.8】
详细步骤
更新版本到 V22.5.9.163
查看官网提供的软件 , 下载对应的版本
K2_A2_V21.4.6.12.bin
K2_V22.5.9.163.bin
刷净化版(带Bread)k2_163_v18_breed.rar
启动telnet/手动安装SSH
3.1. 启动telnet
用 高级设置 - 系统设置 - WebShell 执行命令
1
/www/cgi-bin# /usr/sbin/telnetd -l /bin/login.sh
直接连,不用密码!!
1
winse@DESKTOP-ADH7K1Q:~$ telnet 192.168.2.1
同时修改下密码:
1
2
# 更改root密码为 admin
echo -e 'admin\nadmin' | passwd root
3.2. 安装SSH
这个版本没有带opkg,需要首先把opkg安装好。
直接下载 opkg.zip 然后本地起一个 httpserver 提供一个下载的服务。
1
2
winse@DESKTOP-ADH7K1Q:/mnt/e/SOFTWARE/k2$ python -m SimpleHTTPServer
Serving HTTP on 0.0.0.0 port 8000 ...
在telnet窗口执行:
1
2
3
4
5
6
7
8
9
10
11
12
13
root@K2:/www/cgi-bin# cd /bin
root@K2:/bin# wget http://192.168.2.160:8000/opkg
--2018-06-20 22:50:18-- http://192.168.2.160:8000/opkg
Connecting to 192.168.2.160:8000... connected.
HTTP request sent, awaiting response... 200 OK
Length: 130247 (127K) [application/octet-stream]
Saving to: 'opkg'
opkg 100%[=========================================================================>] 127.19K 176KB/s in 0.7s
2018-06-20 22:50:18 (176 KB/s) - 'opkg' saved [130247/130247]
root@K2:/bin# chmod +x opkg
注意:用完后就删掉吧 rm -rf /bin/opkg
,空间不够!!查看安装了那些软件
1
2
3
4
rm -rf /bin/opkg
root@K2:/overlay# du -sh */*/*
root@K2:/overlay# rm -rf usr/lib/opkg
然后安装ssh:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
opkg install http://downloads.openwrt.org/barrier_breaker/14.07/ramips/mt7620a/packages/base/dropbear_2014.63-2_ramips_24kec.ipk
# 开机自启
/etc/init.d/dropbear enable
# https://openwrt.org/docs/guide-user/base-system/ssh_configuration
# https://wiki.openwrt.org/doc/uci/dropbear
vi /etc/config/dropbear
option GatewayPorts '1'
# 启动
/etc/init.d/dropbear start
uci show dropbear
# 如果需要放开防火墙
iptables -I INPUT 1 -p tcp -m tcp --dport 22 -j ACCEPT
vi /etc/firewall.user
# 删除无用文件
rm -rf /etc/dropbear/dropbear_dss_host_key
注意:需要持久化的话,把这句开放22端口的指令写到 /etc/firewall.user 。
客户端登录:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
winse@DESKTOP-ADH7K1Q:~$ ssh root@192.168.2.1
The authenticity of host '192.168.2.1 (192.168.2.1)' can't be established.
RSA key fingerprint is SHA256:vuAY65qk3Us4MyjYT8KPT8lYsTSTqru6W4e7My6CRkk.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '192.168.2.1' (RSA) to the list of known hosts.
root@192.168.2.1's password:
BusyBox v1.22.1 (2017-02-15 13:52:46 CST) built-in shell (ash)
Enter 'help' for a list of built-in commands.
___ __ _______________ __ _____ ___ ________ ___
/ _ \/ // / _/ ___/ __ \/ |/ / |/ / / __/ __ \/ _ \
/ ___/ _ // // /__/ /_/ / /|_/ / /|_/ / _\ \/ /_/ / ___/
/_/ /_//_/___/\___/\____/_/ /_/_/ /_/ /___/\____/_/
----------------------------------------------------------
Barrier Breaker, unknown
----------------------------------------------------------
PID=K2
BUILD_TYPE=release
BUILD_NUMBER=163
BUILD_TIME=20170215-134532
----------------------------------------------------------
MTK OpenWrt SDK V3.4
revision : adab2180
benchmark : APSoC SDK 5.0.1.0
kernel : 144992
----------------------------------------------------------
root@K2:~#
不推荐用密码,最好使用公钥的方式来处理。但公钥访问有点问题,.ssh的目录权限是个麻烦事 (其实文件的位置不对!!)。
参考: Dropbear public-key authentication HowTo
ssh root@192.168.1.1 “tee -a /etc/dropbear/authorized_keys” < ~/.ssh/id_rsa.pub
把 authorized_keys 文件移到 /etc/dropbear 下面就可以了!
1
2
3
4
5
root@K2:~/.ssh# ls -la
drwx------ 2 root root 0 Jun 21 10:35 .
drwx------ 1 root root 0 Jun 21 08:57 ..
-rw------- 1 root root 397 Jun 21 10:35 authorized_keys
root@K2:~/.ssh# mv authorized_keys /etc/dropbear/
其他拓展
增加空间,挂载windows共享目录
https://blog.vircloud.net/linux/openwrt-psg1218.html
K2 官方版式不带 USB,因此就限制了很多可玩的东西,但是我们可以通过 SMB 挂载的方式来增加存储空间,需要注意的是老毛子挂载 SMB 的方式与其他 OpenWRT 不同,使用 mount 命令是挂载不成功的,正确的方法是:
位置:高级设置 - 自定义设置 - 脚本 - 在路由器启动后执行
配置如下:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
### SMB资源挂载(局域网共享映射,无USB也能挂载储存空间)
### 说明:共享路径填写时,【\】要写成【\\】。
sleep 10
modprobe des_generic
modprobe cifs CIFSMaxBufSize=64512
#mkdir -p /media/cifs
#mount -t cifs \\\\{host}\\{share} /media/cifs -o username={user},password={pass}
mount -t cifs \\\\192.168.31.100\\移动磁盘-C /mnt -o username=guest,password=guest
sleep 10
mdev -s
sleep 5
stop_ftpsamba
sleep 2
run_ftpsamba
sleep 5
Breed进入方式
将要刷的第三方固件准备好。
断电按着reset键不松手,然后通电5秒后再松开reset键。
打开浏览器输入http://192.168.1.1%E5%8D%B3%E5%8F%AFBreed Web恢复控制台(记得先在Breed Web恢复控制台中的固件备份里备份下EEPROM和编程器固件,以后可能用得着)。
恢复固件之前最好在Breed Web恢复控制台恢复一下出厂设置,固件类型:Config区(公版)
参考:
其他参考
–END