从不受信任的计算机使用 ssh 私钥
Use ssh private key from untrusted computer
我目前正在 不受信任的 计算机上进行一个项目,我想 pull/commit 使用 ssh 身份验证从这台(不受信任的)计算机进行更改。我可以访问我的私人(受信任)计算机。以下是我的设置摘要:
- Git 具有访问权限的服务器 仅使用 ssh(不允许 https 身份验证)
- 受信任的计算机可以通过 ssh
访问 git 服务器
- 不受信任的计算机无法访问 git 服务器,但可以访问我受信任的计算机
遇到这种情况你会怎么做? (我无法将文件从不受信任的计算机复制到受信任的计算机。我希望这个项目的文件保留在不受信任的计算机上,但如果我不实际存储它们,我可以将它们发送到受信任的计算机)。他们的主要想法是我不希望其他人使用不受信任的计算机访问我在 git 服务器上的其他项目。
您可能会尝试使用受信任的计算机作为 SSH jump host。
引用this manual:
An alternative to SSH tunneling to access internal machines
through gateway is using jump hosts.
The idea is to use ProxyCommand
to automatically execute ssh command
on remote host to jump to the next host and forward all traffic through.
这可能需要围绕 SSH 客户端编写包装脚本并设置 GIT_SSH
环境。指向它的变量——见
git help git
中的 "ENVIRONMENT VARIABLES" 部分:
GIT_SSH
, GIT_SSH_COMMAND
If either of these environment variables is set then git fetch and git push
will use the specified command instead of ssh when they need to
connect to a remote system. The command will be given exactly two
or four arguments: the username@host
(or just host
) from the
URL and the shell command to execute on that remote system,
optionally preceded by -p
(literally) and the port
from the URL when it specifies something other than the default SSH port.
$GIT_SSH_COMMAND
takes precedence over $GIT_SSH
,
and is interpreted by the shell, which allows additional
arguments to be included. $GIT_SSH
on the other hand must be
just the path to a program (which can be a wrapper shell
script, if additional arguments are needed).
Usually it is easier to configure any desired options through your
personal .ssh/config
file. Please consult your ssh documentation for
further details.
(我相信 SSH_COMMAND
是最近对 Git 的补充。)
我目前正在 不受信任的 计算机上进行一个项目,我想 pull/commit 使用 ssh 身份验证从这台(不受信任的)计算机进行更改。我可以访问我的私人(受信任)计算机。以下是我的设置摘要:
- Git 具有访问权限的服务器 仅使用 ssh(不允许 https 身份验证)
- 受信任的计算机可以通过 ssh 访问 git 服务器
- 不受信任的计算机无法访问 git 服务器,但可以访问我受信任的计算机
遇到这种情况你会怎么做? (我无法将文件从不受信任的计算机复制到受信任的计算机。我希望这个项目的文件保留在不受信任的计算机上,但如果我不实际存储它们,我可以将它们发送到受信任的计算机)。他们的主要想法是我不希望其他人使用不受信任的计算机访问我在 git 服务器上的其他项目。
您可能会尝试使用受信任的计算机作为 SSH jump host。
引用this manual:
An alternative to SSH tunneling to access internal machines through gateway is using jump hosts.
The idea is to use
ProxyCommand
to automatically execute ssh command on remote host to jump to the next host and forward all traffic through.
这可能需要围绕 SSH 客户端编写包装脚本并设置 GIT_SSH
环境。指向它的变量——见
git help git
中的 "ENVIRONMENT VARIABLES" 部分:
GIT_SSH
,GIT_SSH_COMMAND
If either of these environment variables is set then git fetch and git push will use the specified command instead of ssh when they need to connect to a remote system. The command will be given exactly two or four arguments: the
username@host
(or justhost
) from the URL and the shell command to execute on that remote system, optionally preceded by-p
(literally) and the port from the URL when it specifies something other than the default SSH port.
$GIT_SSH_COMMAND
takes precedence over$GIT_SSH
, and is interpreted by the shell, which allows additional arguments to be included.$GIT_SSH
on the other hand must be just the path to a program (which can be a wrapper shell script, if additional arguments are needed).Usually it is easier to configure any desired options through your personal
.ssh/config
file. Please consult your ssh documentation for further details.
(我相信 SSH_COMMAND
是最近对 Git 的补充。)