一、通过SSH隧道登录
1、跳板机配置隧道
1.1登录跳板机 ssh user@xxx.xxx.xxx.xxx -p xxxxx
1.2修改 .ssh/config 配置(如果无此文件,需创建,设置权限 600 chmod 600 .ssh/config),我的配置:
[user@xxx ~]$ cat .ssh/config
Host xxx.xxx.xxx.xxx //跳板机地址
HostName xxx.xxx.xxx.xxx //跳板机IP
User user
Port xxxxx //跳板机端口
RemoteForward 127.0.0.1:30400
备注:使用与其他人不同的本地端口
2、生成SSH秘钥
ssh-keygen -t rsa -b 4096 -C "xxxxxx@email.com"
一直点击enter就行
3、配置本机代理
3.1修改 .ssh/config 配置(如果无此文件,需创建,设置权限 600 chmod 600 .ssh/config),我的配置:
~ cat .ssh/config
Host jump
ForwardAgent yes
ServerAliveInterval 60
ControlMaster auto
HostName 127.0.0.1
Port 30400
User user
Host xxx.xxx.xxx.xxx
HostName %h
Port 22
User user
IdentityFile ~/.ssh/id_rsa
ProxyCommand ssh jump -W %h:%p
备注1:30400端口是本地端口,建议与远程隧道的保持一致
备注2:User user 请更换成自己的帐号
4、打通隧道
4.1连接远程服务器 ssh -L 127.0.0.1:30400:127.0.0.1:30400 user@xxx.xxx.xxx.xxx -p 50022,这里的 30440 换成自己配置的端口
4.2连上以后,在跳板机上再次连接一次 跳板机 ssh user@xxx.xxx.xxx.xxx -p 50022
5、ssh-copy-id -i ~/.ssh/id_rsa.pub user@xxx.xxx.xxx.xxx
将本地秘钥拷贝至远程
6、polysh的使用
1.多台 polysh xxx.xxx.xxx.xxx xxx.xxx.xxx.xxx
2.polysh xxx.xxx.xxx.'<34-36>'