|
本帖最后由 xwsnet 于 2019-4-3 19:29 编辑
我每次重新刷完都会执行下面的步骤,因为我已经把路由器当成一个小型服务器了,仅供参考.
注: 装SSH是因为自己需要做隧道,dropbear 属于精简版的SSH,功能有限.
### 1:然后后安装以下包,luci一般已经安装
opkg update
opkg install luci-ssl
opkg install luci-i18n-base-zh-cn
opkg install luci-i18n-firewall-zh-cn
opkg install ddns-scripts
opkg install luci-app-ddns
opkg install luci-i18n-ddns-zh-cn
opkg install openssh-server
opkg install openssh-sftp-server
opkg install curl
opkg install nmap
opkg install tcpdump
opkg install shadow-su
opkg install lsof
opkg install bind-dig
opkg install s-s-libev-ss-server
####安装openvirtual**
opkg install openvirtual**
opkg install luci-app-openvirtual**
opkg install luci-i18n-openvirtual**-zh-cn
## 解决 openssl 报错的补丁
opkg install openssl-util
### 2:SSH 手动生成以下两种key
[ -f /etc/ssh/ssh_host_ed25519_key ] || ssh-keygen -t ed25519 -f /etc/ssh/ssh_host_ed25519_key
[ -f /etc/ssh/ssh_host_ecdsa_key ] || ssh-keygen -t ecdsa -f /etc/ssh/ssh_host_ecdsa_key
[ -f /etc/ssh/ssh_host_dsa_key ] || ssh-keygen -t dsa -f /etc/ssh/ssh_host_dsa_key
##### 生成moduli 素数模数,必须在其他linux服务器中生成后将moduli文件拷到路由器上
### 由于安全的素数模数生成很耗时间,可以直接拷贝已经生成的素数模数moduli.safe到服务器 /etc/ssh/moduli
## 注: 本步骤一般是从原来的拷贝,因为路由器CPU性能差,这一步要执行很久
ssh-keygen -G /etc/ssh/moduli.all -b 4096
ssh-keygen -T /etc/ssh/moduli.safe -f /etc/ssh/moduli.all
mv /etc/ssh/moduli.safe /etc/ssh/moduli
rm /etc/ssh/moduli.all
### 4: 禁用dropbear
rm /etc/rc.d/S50dropbear
rm /etc/rc.d/S19dropbear
rm /etc/rc.d/K50dropbear
### 如想启用dropbear则执行以下命令
# ln -s ../init.d/dropbear S50dropbear
# ln -s ../init.d/dropbear K50dropbear
### 5: 安装完毕后需要修改/etc/ssh/sshd_config中相关配置
### 将以下内容添加到文件/etc/ssh/sshd_config末尾
Port 50022
PermitRootLogin yes
GatewayPorts yes
TCPKeepAlive yes
ClientAliveInterval 12
ClientAliveCountMax 3
MaxAuthTries 3
### 6: 添加alias别名
echo "alias n='netstat -anptu'" >> /etc/profile
echo "alias p='ps'" >> /etc/profile
echo "alias d='df -h'" >> /etc/profile
|
|