Windows 中是否有已知主机的明确路径?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/32945533/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Is there a definitive path for known hosts in Windows?
提问by Stefano Mtangoo
I'm working with libcurl as SFTP and its great. I want to check for the host am about to connect if it exists in the hosts file. In Linux I can easily find known hosts file as it is almost always in ~/.ssh/known_hosts
. I wanted to know if Windows maintains the same thing or there is no standard as to where such file resides in Windows.
我正在使用 libcurl 作为 SFTP,它很棒。我想检查主机是否存在于主机文件中。在 Linux 中,我可以轻松找到已知的主机文件,因为它几乎总是在~/.ssh/known_hosts
. 我想知道 Windows 是否维护相同的东西,或者没有关于此类文件在 Windows 中的位置的标准。
采纳答案by Martin Prikryl
The ~/.ssh/known_hosts
is a *nix path used by OpenSSH. The ~
is resolved to the account's home directory, which is specified in /etc/passwd
file. The home defaults to /home/username
folder.
这~/.ssh/known_hosts
是 OpenSSH 使用的 *nix 路径。将~
解析为帐户的主目录,该目录在/etc/passwd
文件中指定。主页默认为/home/username
文件夹。
The OpenSSH is Linux software. It does not run on Windows on its own.
OpenSSH 是 Linux 软件。它不能单独在 Windows 上运行。
Though it can run on *nix emulation on Windows and there are also Windows clones of OpenSSH. So in the end, your question is about what emulation or clone do you run on the Windows server and how that maps/re-implements the access to ~/.ssh/known_hosts
.
虽然它可以在 Windows 上的 *nix 仿真上运行,但也有 OpenSSH 的 Windows 克隆。所以最后,你的问题是你在 Windows 服务器上运行什么模拟或克隆,以及它如何映射/重新实现对~/.ssh/known_hosts
.
Win32-OpenSSH(Windows clone of OpenSSH by Microsoft): It goes to your Windows account profile folder. I.e. typically to
C:\Users\username\.ssh
.See also my guide for Setting up SSH public key authentication on Win32-OpenSSH.
Cygwin emulator: On my installations, all *nix-like paths are actually stored in
C:\cygwin64
(C:\cygwin
on 32-bit).So the
/home/username/.ssh/known_hosts
is inC:\cygwin64\home\username\.ssh\known_hosts
.
Win32-OpenSSH(Microsoft 对 OpenSSH 的 Windows 克隆):它转到您的 Windows 帐户配置文件文件夹。即通常到
C:\Users\username\.ssh
.另请参阅我的在 Win32-OpenSSH 上设置 SSH 公钥身份验证的指南。
Cygwin 模拟器:在我的安装中,所有类似 *nix 的路径实际上都存储在
C:\cygwin64
(C:\cygwin
32 位) 中。所以
/home/username/.ssh/known_hosts
在C:\cygwin64\home\username\.ssh\known_hosts
.
Note that Windows SSH clients usually do not use the known_hosts
. They have a different host key cache/storage.
请注意,Windows SSH 客户端通常不使用known_hosts
. 它们具有不同的主机密钥缓存/存储。
For example widely used Windows SSH client, PuTTY, stores know host keys to Windows registry to HKCU\Software\SimonTatham\PuTTY\SshHostKeys
key. For details, see the answer by @aneesh.
例如,广泛使用的 Windows SSH 客户端 PuTTY 将已知主机密钥存储到 Windows 注册表中HKCU\Software\SimonTatham\PuTTY\SshHostKeys
。有关详细信息,请参阅@aneesh的答案。
回答by i486
Look in ~\Users\~\AppData\Roaming\_ssh\known_hosts
.
查找范围~\Users\~\AppData\Roaming\_ssh\known_hosts
。
See also: http://comments.gmane.org/gmane.comp.web.curl.general/12593
另见:http: //comments.gmane.org/gmane.comp.web.curl.general/12593
回答by aneesh
Not sure about libcurl though. But, for PuTTY users this might be helpful if the PuTTY throws warnings such as WARNING: Server public key has changed
So in window known_hosts for PuTTY is SshHostKeys.
虽然不确定 libcurl。但是,对于 PuTTY 用户,如果 PuTTY 在 PuTTY 的WARNING: Server public key has changed
窗口 known_hosts is SshHostKeys 中抛出诸如So 之类的警告,这可能会有所帮助。
that is stored at the HKEY_CURRENT_USER\Software\SimonTatham\PuTTY\SshHostKeys
location. To reach that location Registry Editor
supposed to be used.
存储在该HKEY_CURRENT_USER\Software\SimonTatham\PuTTY\SshHostKeys
位置。到达Registry Editor
应该使用的位置。
- go to start look for
regedit
- then you will see all the directories on the left pane under computer
- just like this image says go to
HKEY_CURRENT_USER\Software\SimonTatham\PuTTY\SshHostKeys
location - location - then you can modify like you wish Known host options- delete the registry value if you see a warning says
WARNING: Server public key has changed
- If needed you can check the content in the
SshHostKeys
file using this commandREG QUERY HKEY_CURRENT_USER\Software\SimonTatham\PuTTY\SshHostKeys
- 去开始寻找
regedit
- 然后您将在计算机下的左窗格中看到所有目录
- 就像这张图片说的去
HKEY_CURRENT_USER\Software\SimonTatham\PuTTY\SshHostKeys
位置 -位置 - 然后您可以根据需要进行修改已知主机选项- 如果您看到警告,请删除注册表值
WARNING: Server public key has changed
- 如果需要,您可以
SshHostKeys
使用此命令检查文件中的内容REG QUERY HKEY_CURRENT_USER\Software\SimonTatham\PuTTY\SshHostKeys
And then the cache will be cleared. Will be everything new again for that particular entry
然后缓存将被清除。该特定条目将再次成为新事物