一种在 SSH 隧道中指定与正在使用的主机不同的主机的方法

发布于 2024-09-04 02:31:34 字数 755 浏览 3 评论 0原文

我正在尝试设置 SSH 隧道来访问 Beanstalk(以绕过烦人的代理服务器)。

我可以让它工作,但有一个警告:我必须将主机文件中的 Beanstalk 主机 URL (username.svn.beanstalkapp.com) 映射到 127.0.0.1(并在设置时使用 ip 代替域)隧道)。

原因(我认为)是我正在使用本地 SSH 实例(在 Snow Leopard 上)创建隧道,如果我在与 Beanstalk 通信时使用 localhost 或 127.0.0.1,它会拒绝授权凭据。我相信这是因为 Beanstalk 使用请求中指定的主机名来确定应检查哪个帐户的用户名/密码组合。如果使用 localhost,我认为请求中缺少此信息(以 Beanstalk 所需的某种方式)。

目前,我挖掘了 username.svn.beanstalkapp.com 的 IP,将 username.svn.beanstalkapp.com 映射到主机文件中的 127.0.0.1,然后对于隧道,我使用以下命令:

ssh -L 8080:ip:443 -p 22 -l tom -N 127.0.0.1

我可以告诉 Subversion 该存储库。位于:

https://username.svn.beanstalkapp.com:8080/repo-name

这使用我的隧道,并且接受用户名和密码。

所以,我的问题是,在设置 SSH 隧道时是否有一个选项,这意味着我不必使用主机文件解决方法?

I am trying to setup an SSH tunnel to access Beanstalk (to bypass an annoying proxy server).

I can get this to work, but with one caveat: I have to map my Beanstalk host URL (username.svn.beanstalkapp.com) in my hosts file to 127.0.0.1 (and use the ip in place of the domain when setting up the tunnel).

The reason (I think) is that I am creating the tunnel using the local SSH instance (on Snow Leopard) and if I use localhost or 127.0.0.1 when talking to Beanstalk, it rejects the authorisation credentials. I believe this is because Beanstalk use the hostname specified in a request to determine which account the username / password combination should be checked against. If localhost is used, I think this information is missing (in some manner which Beanstalk requires) from the requests.

At the moment I dig the IP for username.svn.beanstalkapp.com, map username.svn.beanstalkapp.com to 127.0.0.1 in my hosts file, then for the tunnel I use the command:

ssh -L 8080:ip:443 -p 22 -l tom -N 127.0.0.1

I can tell Subversion that the repo. is located at:

https://username.svn.beanstalkapp.com:8080/repo-name

This uses my tunnel and the username and password are accepted.

So, my question is if there is an option when setting up the SSH tunnel which would mean I wouldn't have to use my hosts file workaround?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

稚然 2024-09-11 02:31:34

我将在您的主机文件中添加一个条目,将 127.0.0.1 映射到您需要的主机名,然后使用该主机名连接到您的隧道。

更新
在我看来,hosts 文件是你最好的选择。

I would add an entry to your hosts file that maps 127.0.0.1 to the hostname you need and then use the hostname to connect to your tunnel.

Update
The hosts file is IMO your best option.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文