目的是为了不使用密码登录
登录(默认应该是dropbear)
先装openssh
opkg update
opkg install openssh
路由器运行ssh-keygen
,文件暂时放在/tmp/id_rsa
,输入一个passphrase
,记住。
把/tmp/id_rsa.pub
的一行复制到/root/.ssh/authorized_keys
把/tmp/id_rsa
拷出来,putty要用它来登录
下载puttygen.exe
,Conversions -> Import Key,选择刚才的id_rsa文件,输入前面的passphrase
点Save private key,把私钥保存好
修改/etc/ssh/sshd_config
为如下
RSAAuthentication yes #RSA认证
PubkeyAuthentication yes #开启公钥验证
AuthorizedKeysFile /root/.ssh/authorized_keys #验证文件路径
PasswordAuthentication no #禁止密码认证
PermitEmptyPasswords yes #禁止空密码
UsePAM no #禁用PAM
让sshd自动启动
/etc/init.d/sshd enable
关闭当前ssh会话
在web页面关闭dropbear,禁用dropbear自启动,打开sshd
打开putty填IP,在Connection -> SSH -> Auth 选择前面的私钥,登录。
会询问用户名,填写。
会询问Passphrase,填写。
应该就好了。。
.ssh 目录的权限必须是0700
.ssh/authorized_keys 文件权限必须是0600
没好的话。在web页面弄回dropbear再说吧。
好了的话,可以把dropbear删了。