如何使用 ssh 隧道添加 CA(证书颁发机构)?

问题描述 投票:0回答:1

我有几个 shh 隧道指向不同的“remotes_servers”,如下所示:

ssh -fN -L local_port:remote_server:remote_port user@gateway

因此,在我的本地计算机中

localhost:local_port
指向
remote_server:remote_port
,问题是某些
remote_server
需要自定义 CA 证书。

当我尝试做类似的事情时:

curl --cacert CA.pem https://localhost:local_port

我有一个错误“没有替代证书主题名称与目标主机名'localhost'匹配”,这是真的,因为我指向

localhost
而不是
remote_server

可以使用

--insecure
中的
curl
--config http.sslVerify=false
中的
git
等建立连接。我想避免这种类型的方法。

我想找到一种方法来表明,在客户端,

localhost:local_port
两者(不仅仅是
localhost
)与
remote_server:remote_port
相同,我还有其他端口指向不同的
remote servers
,始终使用
localhost 
.

bash ubuntu ssh openssh ssh-tunnel
1个回答
0
投票

您可以编辑 /etc/hosts 文件,以便

remote_server
实际上映射到
localhost
(然后将浏览器指向
https://remote_server:local_port
)。

也就是说,如果我更新我的

/etc/hosts
文件,这样我就有:

127.0.0.1 localhost localhost.localdomain google.com

我设置了 SSH 端口转发,例如:

ssh -L 8443:google.com:443 some.remote.server

然后运行没有错误:

curl https://google.com:8443
© www.soinside.com 2019 - 2024. All rights reserved.