在本地机器 1)ssh-keygen 2)ls ~/.ssh/ 应该有三个文件id_rsa id_rsa.pub known_hosts 拷贝id_rsa.pub到远程服务器,然后在远程服务器运行3) cat id_rsa.pub >> ~/.ssh/authorized_keys 验证不需要输入密码就可以ssh从本地到远程 本地机器 4)解压缩附件的autossh5) 编译下载地址:http://www.wudonghang.com/downloads/autossh/autossh-1.4c.tgz 或 ftp://www.wudonghang.com/downloads/autossh/autossh-1.4c.tgz具体步骤如下
- gunzip -c autossh-1.4c.tgz | tar xvf –
- cd autossh-1.4c
- ./configure
- make all
- make install
安装完了,应该在/usr/local下面 运行autossh -f -M 5678 -NR 10000:localhost:22 root@x.x.x.xx.x.x.x是远程服务器10000是连接端口5678是监控端口 运行完毕后,登录到远程服务器 然后运行 ssh localhost -p 10000就可以反向连接了。 信息 本地端 /usr/local/bin/autossh -f -M 5678 -NR 10000:localhost:12222 -p12222 root@182.92.130.221远程端访问(用的saltstack) ssh wudonghang@localhost -p 10000有时候 -f不好使 autossh -M 5678 -NR 10000:localhost:12222 root@220.171.106.6 -p 43322&加入PATHA环境变量,/etc/profile里面搜索patc 加 :/usr/local/bin/autossh 来自为知笔记(Wiz)