快速ssh代理
rsp的Python项目详细描述
rsp
快速ssh代理。就像ssh -ND
,但速度快得多。
rsp
是一个ssh客户端,它实现ssh协议的socks5代理特性。此实现的关键特征是使用多个连接来克服在单个SSH会话中复用多隧道TCP连接的缺点。多个会话不受单个连接的TCP窗口大小的限制,数据包丢失不会同时影响所有隧道连接。为了减少连接建立的延迟,rsp
维护稳定连接池,该池以可配置的速率补充。
功能
- 与传统的openssh客户端相比,速度更快。
- 跨平台(Windows、Linux、macOS和其他类Unix系统)
- 服务器不需要安装程序。
rsp
可以立即用于任何ssh服务器。 - 自给自足:不需要客户端的openssh来操作。
- socks5远程dns支持。
- 对具有异步连接池的用户隐藏连接建立延迟。
- 连接建立速率限制保护用户免受ssh洪水的威胁。
性能
通过100Mbps连接测试Debian9服务器到服务器的往返时间为128ms,平均丢包率约为0.5%
客户端是Linux桌面(Fedora30、Python3.7.3、OpenSSH 8.0p1)
OpenSSH | rsp |
---|---|
安装
Python 3.5.3+必需
来自PyPI:
pip3 install rsp
从源(在源目录中运行):
pip3 install .
Windows注意:请确保已安装Python3并将可执行文件位置添加到PATH环境变量中(这是安装期间可用的选项)还要确保从管理员命令行运行install命令。
概要
代理
$ rsp --help
usage: rsp [-h] [-v {debug,info,warn,error,fatal}] [-l FILE]
[--disable-uvloop] [-a BIND_ADDRESS] [-p BIND_PORT] [-n POOL_SIZE]
[-B BACKOFF] [-w TIMEOUT] [-r CONNECT_RATE] [-L LOGIN]
[-I KEY_FILE] [-P PASSWORD] [-H FILE]
[--client-version CLIENT_VERSION]
dst_address [dst_port]
Rapid SSH Proxy
positional arguments:
dst_address target hostname
dst_port target port (default: 22)
optional arguments:
-h, --help show this help message and exit
-v {debug,info,warn,error,fatal}, --verbosity {debug,info,warn,error,fatal}
logging verbosity (default: info)
-l FILE, --logfile FILE
log file location (default: None)
--disable-uvloop do not use uvloop even if it is available (default:
False)
listen options:
-a BIND_ADDRESS, --bind-address BIND_ADDRESS
bind address (default: 127.0.0.1)
-p BIND_PORT, --bind-port BIND_PORT
bind port (default: 1080)
pool options:
-n POOL_SIZE, --pool-size POOL_SIZE
target number of steady connections (default: 30)
-B BACKOFF, --backoff BACKOFF
delay after connection attempt failure in seconds
(default: 5)
-w TIMEOUT, --timeout TIMEOUT
server connect timeout (default: 4)
-r CONNECT_RATE, --connect-rate CONNECT_RATE
limit for new pool connections per second (default:
0.5)
SSH options:
-L LOGIN, --login LOGIN
SSH login. Default is name of current user (default:
None)
-I KEY_FILE, --identity KEY_FILE
SSH private key file. By default program looks for SSH
keys in usual locations, including SSH agent socket.
This option may be specified multiple times (default:
None)
-P PASSWORD, --password PASSWORD
SSH password. If not specified, password auth will be
disabled (default: None)
-H FILE, --hosts-file FILE
overrides known_hosts file location (default:
/home/user/.rsp/known_hosts)
--client-version CLIENT_VERSION
override client version string (default: None)
用法示例
注意:在代理操作之前,必须将主机密钥添加到受信任列表中请参阅rsp-trust
实用程序的概要。
使用端口22上的SSH连接example.com,使用默认池大小,并接受端口1080上的SOCKS5连接身份验证使用ssh代理和用户名root
。
rsp -L root example.com
使用端口2222上的ssh连接example.net,使用文件proxy_key
中的私钥和用户名user
。
rsp -I proxy_key -L user example.net 2222
使用当前用户的密码和用户名,在端口22上使用ssh连接example.com:
rsp -P MyGoodPassword example.com
信任管理实用程序
$ rsp-trust --help
usage: rsp-trust [-h] [-H FILE] dst_address [dst_port]
Rapid SSH Proxy: TOFU key trust utility
positional arguments:
dst_address target hostname
dst_port target port (default: 22)
optional arguments:
-h, --help show this help message and exit
SSH options:
-H FILE, --hosts-file FILE
overrides known_hosts file location (default:
/home/user/.rsp/known_hosts)
用法示例
从example.com端口22获取主机密钥
rsp-trust example.com
从example.net的2222端口获取主机密钥,并使用受信任密钥文件的非默认位置:
rsp-trust -H myhostkeysfile example.net 2222
密钥生成实用程序
$ rsp-keygen --help
usage: rsp-keygen [-h] [-f FILE]
[-t {ssh-ed25519,ssh-rsa,ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521,ssh-dss}]
[-b BITS]
Rapid SSH Proxy: key generation utility
optional arguments:
-h, --help show this help message and exit
-f FILE, --file FILE output file name (default: proxy_key)
-t {ssh-ed25519,ssh-rsa,ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521,ssh-dss}, --type {ssh-ed25519,ssh-rsa,ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521,ssh-dss}
key type (default: ssh-ed25519)
-b BITS, --bits BITS key type (default: 2048)
用法示例
生成具有良好默认参数的ssh密钥:
rsp-keygen
私钥和公钥将分别保存到proxy_key
和proxy_key.pub
。