标签 ssh 下的文章

Openwrt配置ssh自动登录服务器socks5转发

1.首先安装openssh客户端。

rm -rf /usr/bin/ssh #删除ssh软链接
rm -rf /usr/bin/scp #删除scp软链接
opkg update #更新列表
opkg install openssh-client openssh-keygen#安装openssh客户端

 2.Openwrt生在ssh密钥并上传到服务器端:http://www.l-yp.com/1140.html

3.实现ssh转发:

ssh -D 7070 用户@IP -p端口(22可去除这个参数)-qTfnN

开机启动:

echo 'ssh -D 7070 用户@IP -p端口(22可去除这个参数)-qTfnN >/dev/null 2>&1 &' >> /etc/rc.local

shell脚本监控ssh自动重新连接:

#!/bin/bash
while true
do
if netstat -tlnp|grep ":7070"
then
echo "ssh is working"
else
ssh -D 7070 用户@IP -p端口(22可去除这个参数)-qTfnN >/dev/null 2>&1 &
fi
sleep 300 
done

linux SSH单用户密钥登陆

$ ssh-keygen -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/home/test/.ssh/id_rsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /home/test/.ssh/id_rsa.
Your public key has been saved in /home/test/.ssh/id_rsa.pub.
The key fingerprint is:15:b0:02:35:b4:0d:d3:fe:9c:e8:56:e1:a6:06:8c:e9 test@asianux3

创建密钥。

然后拷贝公钥到服务器上:将.ssh/id_rsa.pub 上传到服务器并且重命名 ~/.ssh/authorized_keys  

设置权限600.