私钥登录跳板机,跳板机如何用密码验证的方式登录目标机器?

2016-10-12 18:47:32 +08:00
 boogiefer

想要实现的:

客户端(私钥) -> 跳板机(公钥) -> 目标机器 1 、目标机器 2 (密码验证)

客户端用私钥登录跳板机,想用密码验证的方式登录不通的内网机器

现在的配置:

  1. 跳板机有外网 IP , ssh_config 文件禁用了密码验证 PasswordAuthentication no,存放了公钥;
  2. 内网机器都是密码验证登录,没有启用密钥验证方式的登录;

碰到的问题:

跳板机会默认使用密钥验证的方式去登录内网机器,并且不会尝试密码验证的方式登录。

5599 次点击
所在节点    Linux
10 条回复
paulw54jrn
2016-10-12 18:50:16 +08:00
ssh -A

https://www.freebsd.org/cgi/man.cgi?query=ssh&sektion=1

```
-A Enables forwarding of the authentication agent connection. This
can also be specified on a per-host basis in a configuration
file.

Agent forwarding should be enabled with caution. Users with the
ability to bypass file permissions on the remote host (for the
agent's UNIX-domain socket) can access the local agent through
the forwarded connection. An attacker cannot obtain key material
from the agent, however they can perform operations on the keys
that enable them to authenticate using the identities loaded into
the agent.
```
paulw54jrn
2016-10-12 18:50:57 +08:00
我看错了.. 请忽略我
boogiefer
2016-10-12 18:58:56 +08:00
@paulw54jrn `- A` 命令是用来转发密钥的,内网机器并不支持密钥验证的方式登录
xqin
2016-10-12 19:06:40 +08:00
1. ssh 至跳板机, 并增加 -L 参数, 比如 -L 1234:目标机器 IP:端口
2. 在完成上面这一步的时候,在 `客户端` 连接 127.0.0.1:1234 使用密码来登陆 目标机器.

简单点讲就是 由`跳板机`做一下端口转发, 把 `目标机器`的`ssh 端口`转发过来, 然后在`客户端`上登陆`目标机器`.
boogiefer
2016-10-12 19:11:58 +08:00
@xqin 感谢答复,你的方法还没验证;

我发现在跳板机 ~/.ssh/config 配置里面,添加内网 Host 并且把 `PasswordAuthentication` 设置成 `yes` 就可以了
xqin
2016-10-12 19:13:08 +08:00
再或者 使用 -F 参数, 重新指定 ssh_config 文件, 不让它使用系统默认的(在跳板机上登陆目标机器的时候).
xqin
2016-10-12 19:15:28 +08:00
`man ssh_config` 即可得到如下帮助信息:

SSH_CONFIG(5) BSD File Formats Manual SSH_CONFIG(5)

NAME
ssh_config — OpenSSH SSH client configuration files

SYNOPSIS
~/.ssh/config
/etc/ssh/ssh_config

DESCRIPTION
ssh(1) obtains configuration data from the following sources in the fol ‐
lowing order:

1. command-line options
2. user's configuration file (~/.ssh/config)
3. system-wide configuration file (/etc/ssh/ssh_config)
raysonx
2016-10-12 21:14:16 +08:00
不明白为何要在跳板机 ssh_config 里禁止 ssh 客户端,注意客户端,禁止密码认证。
应该是在 sshd_config 里禁止,而不是 ssh_config 。前者管别人登他,后者管他登别人。
ywgx
2016-10-12 21:44:14 +08:00
去看看 xabcloud.com 的设计
likuku
2016-10-14 02:02:40 +08:00
跳板鸡上的 ~/.ssh/config 里 添加:
ForwardAgent no

即可

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/312298

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX