标签 OpenSSH 下的文章

-L 本地端口转发

-R 远程端口转发

-D 动态端口转发

Example

# 本地端口转发
# 本地监听端口 9848,用户访问本机的 9848端口,最终访问 HostC的9848端口,通过HostB中转
ssh -L 9848:HostC:9848 user@HostB -N

# 远程端口转发
# 远程主机HostB监听端口 9848
# 用户访问HostB的 9848端口,最终访问 HostA 的9848端口,通过HostA中转
ssh -R 9848:localhost:9848 user@HostB -N

# 动态端口转发
# 本地监听1080端口 SOCKS5协议
# 用户配置本机的1080作为代理,http请求,会通过代理端口转到HostB,然后通过HostB访问http请求
ssh -D 1080 user@HostB -N

- 阅读剩余部分 -

通过ssh连接服务器失败

$ ssh root@172.16.0.247
Unable to negotiate with 172.16.0.247 port 22: no matching host key type found. Their offer: ssh-rsa,ssh-dss

SSH 客户端和远程服务器无法协商使用相同的 host key 类型。

解决方法:

添加参数

# -oHostKeyAlgorithms=+ssh-rsa           允许接收远程主机提供的 ssh-rsa 类型的 主机密钥(连接握手阶段)
# -oPubkeyAcceptedAlgorithms=+ssh-rsa    允许使用 ssh-rsa 类型的 用户身份验证公钥(登录认证阶段)
ssh root@172.16.0.247 -oHostKeyAlgorithms=+ssh-rsa -oPubkeyAcceptedAlgorithms=+ssh-rsa

- 阅读剩余部分 -