使用 ssh 通过命令行将特定密钥转发到
Forward a specific key to via the command line using ssh
有没有办法让 ssh-agent 转发未在 ~/.ssh/config
中配置的特定密钥。例如,我像这样连接到 ec2 上的主机:
ssh -At -i ssh/insecure-deployer ec2-user@$bastion-instance-dns
甚至像这样直接连接到我的堡垒实例后面的实例:
ssh -At -i ssh/insecure-deployer ec2-user@$bastion-instance-dns ssh ubuntu@target-instance-ip
在这种情况下,我想要做的是让代理转发我用来连接堡垒实例的相同密钥,即 ssh/insecure-deployer
密钥,但似乎只有密钥~/.ssh/config 正在转发中。
我意识到出了什么问题。我需要将我的密钥添加到代理:
ssh-add -L
没有列出密钥。
通过以下方式添加密钥:
ssh-add ssh/insecure-deployer
和:
ssh -At -i ssh/insecure-deployer ec2-user@$bastion-instance-dns ssh ubuntu@target-instance-ip
如愿以偿。
有没有办法让 ssh-agent 转发未在 ~/.ssh/config
中配置的特定密钥。例如,我像这样连接到 ec2 上的主机:
ssh -At -i ssh/insecure-deployer ec2-user@$bastion-instance-dns
甚至像这样直接连接到我的堡垒实例后面的实例:
ssh -At -i ssh/insecure-deployer ec2-user@$bastion-instance-dns ssh ubuntu@target-instance-ip
在这种情况下,我想要做的是让代理转发我用来连接堡垒实例的相同密钥,即 ssh/insecure-deployer
密钥,但似乎只有密钥~/.ssh/config 正在转发中。
我意识到出了什么问题。我需要将我的密钥添加到代理:
ssh-add -L
没有列出密钥。
通过以下方式添加密钥:
ssh-add ssh/insecure-deployer
和:
ssh -At -i ssh/insecure-deployer ec2-user@$bastion-instance-dns ssh ubuntu@target-instance-ip
如愿以偿。