【问题标题】:ssh key not working on mac machinesssh 密钥在 mac 机器上不起作用
【发布时间】:2019-01-10 01:59:24
【问题描述】:

我的.ssh 文件中已经有id_rsa 密钥(带有密码)

现在,我想添加新密钥,这样我就可以使用 ssh 连接到服务器而无需密码。

我喜欢这样做:

ssh-keygen -t rsa
>> /Users/markoz/.ssh/id_rsa_new
>> Passphrase:

现在我在 .ssh 文件夹中有两个键

.ssh $ ls
id_rsa    id_rsa.pub    id_rsa_new    id_rsa_new.pub    known_hosts

现在如果我将id_rsa_new.pub 密钥复制到服务器authorized_keys 中,它不起作用(它要求我输入密码)

但如果我将 id_rsa.pub 密钥的密钥复制到服务器 authorized_keys 中,它可以工作(要求输入密码)

我错过了什么吗?有规定只能使用一个kew吗?

【问题讨论】:

标签: macos ssh-keys ssh-keygen


【解决方案1】:

默认情况下 ssh 采用~/.ssh/id_rsa 密钥。如果不同,您应该明确指定它 - 例如,使用 $ ssh -i ~/.ssh/id_rsa_new host

【讨论】:

  • 我可以指定女巫密钥用于女巫主机吗? (不是每次)
  • 为此您需要创建~/.ssh/config 文件(IdentityFile 选项定义要使用的私钥)。参考ssh.com/ssh/config
  • 抱歉,没找到你
猜你喜欢
  • 1970-01-01
  • 2012-07-07
  • 2013-02-20
  • 2015-11-19
  • 1970-01-01
  • 2018-03-17
  • 1970-01-01
  • 2017-03-25
  • 2020-07-21
相关资源
最近更新 更多