强制使用ssh协议版本1
强制使用ssh协议版本2
强制使用IPv4地址
强制使用IPv6地址
开启认证代理连接转发功能
关闭认证代理连接转发功能
使用本机指定地址作为对应连接的源ip地址
请求压缩所有数据
动态转发有点更加强劲的端口转发功能,即是无需固定指定被访问目标主机的端口号。这个端口号需要在本地通过协议指定,该协议就是简单、安全、实用的 SOCKS 协议。
ssh -D 50000 user@host1
这条命令创建了一个SOCKS代理,所以通过该SOCKS代理发出的数据包将经过
host1
转发出去。
指定ssh指令的配置文件
后台执行ssh指令
允许远程主机连接主机的转发端口
指定身份文件
指定连接远程服务器登录用户名
本地转发,顾名思义就是把本地主机端口通过待登录主机端口转发到远程主机端口上去。
ssh -L 0.0.0.0:50000:host2:80 user@host1
这条命令将
host2
的80端口映射到本地的50000端口,前提是待登录主机host1
上可以正常连接到host2
的80端口。
不执行远程指令
指定配置选项
Can be used to give options in the format used in the configuration file. This is useful for specifying options for which there is no separate command-line flag
指定ssh 超时时间
ssh -o ServerAliveInterval=30 user@host
Automatically accept keys
ssh -oStrictHostKeyChecking=no $h
Force SSH client to use password authentication instead of public key
ssh -o PreferredAuthentications=password -o PubkeyAuthentication=no user@host
Force SSH client to use password authentication instead of public key
ssh -o PreferredAuthentications=password -o PubkeyAuthentication=no user@host
ssh -o "ProxyCommand nc --proxy-type socks5 --proxy 127.0.0.1:9050 %h %p" <target_host>
ssh -o "ProxyCommand= nc -X 5 -x 127.0.0.1:9050 %h %p" user@host
To do it on a per-host basis, edit your ~/.ssh/config to look something like this:
host example.com user bar port 22 ProxyCommand nc --proxy-type socks5 --proxy 127.0.0.1:9050 %h %p
Add this to your ssh config file (~/.ssh/config
):
host * CheckHostIP no Compression yes Protocol 2 ProxyCommand connect -4 -S localhost:9050 $(tor-resolve %h localhost:9050) %p
git clone https://github.com/ghostlyman/connect-proxy.git cd connect make gcc connect.c -o connect cp connect /usr/local/bin
ssh -o "ProxyCommand connect -S 127.0.0.1:1080 %h %p" user@host
指定远程服务器上的端口
静默模式
远程转发是指把登录主机所在网络中某个端口通过本地主机端口转发到远程主机上。
sshd_config里要打开AllowTcpForwarding
选项,否则-R
远程端口转发会失败。
默认转发到远程主机上的端口绑定的是127.0.0.1
,如要绑定0.0.0.0
需要打开sshd_config里的GatewayPorts
选项。这个选项如果由于权限没法打开也有办法,可配合ssh -L
将端口绑定到0.0.0.0
ssh -R 0.0.0.0:8080:host2:80 user@host1
这条命令将
host2
的80端口映射到待登录主机host1的8080端口,前提是本地主机可以正常连接host2
的80端口。
Force pseudo-tty allocation
This can be used to execute arbitrary screen-based programs on a remote machine, which can be very useful
Multiple -t options force tty allocation, even if ssh has no local tty
开启X11转发功能
关闭X11转发功能
开启信任X11转发功能
Host * ServerAliveInterval 60
Host *
#表示需要启用该规则的服务端(域名或ip)
ServerAliveInterval 60
#表示没60秒去给服务端发起一次请求消息(这个设置好就行了)
ServerAliveCountMax 3
#表示最大连续尝试连接次数(这个基本不用设置)