ssh - 从服务器获取指纹

标签 ssh ssh-keys

如果我只有服务器的 IP 地址并且该服务器未在我的 ~/.ssh/known_hosts 文件中列出,如何从服务器获取 SSH 指纹?

我想查看一些主机 key 。这是我在 Ruby 中尝试过的:

net_ssh_session =
  Net::SSH::Transport::Session.new(
    target, :port => port, :timeout => timeout, :paranoid => Net::SSH::Verifiers::Null.new)
host_keys = net_ssh_session.host_keys

如果服务器未在我的 ~/.ssh/known_hosts 中列出,我无法获取任何主机 key 。

最佳答案

引用我文章的重要部分Where do I get SSH host key fingerprint to authorize the server?

You should get an SSH host key fingerprint along with your credentials from a server administrator. Knowing the host key fingerprint and thus being able to verify it is an integral part of securing an SSH connection. It prevents man-in-the-middle attacks.

In the real world, most administrators do not provide the host key fingerprint.

Instead you can ask anyone else who has a physical access to the server or who already knows the host key. The host key is only one and hence the same for all users. Also note that the host key fingerprint is generated from a public key part of the host key only. So it is not secret and can be safely sent over an unencrypted (yet trusted) communication channels.

If you do not have anyone else to obtain the fingerprint from, you may need to connect to the server without knowing the fingerprint. Before connecting for the first time, ensure a security of your local machine and a line to the server. For example if you plan to connect to the server from an external site (e.g. from home or a client), but you have a physical access to the server site, connect from the server site the first time (e.g. your workplace).

关于ssh - 从服务器获取指纹,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40189430/

相关文章:

linux - 使用 Windows IDE 在 Linux 上处理远程项目

ssh - 加 salt 和管理 .ssh/authorized_keys

git - 在服务器上设置 Git/Bitbucket : Permission Issues

c# - 立即停止所有 SSH 连接

python - 远程运行 python 脚本的更好方法

通过 ssh 调用 write()

ruby-on-rails - 无法运行上限生产部署:使用 Net::SSH::AuthenticationFailed 初始化:用户身份验证失败?

git - SSH 在 Windows 上查找公钥/私钥对的错误位置

Linux crontab 脚本通过 ssh 登录到本地用户

github - 不能推送,git一个repo,一个用户,两台电脑