我正在跟踪ssh github教程,我对ssh-add和ssh-agent之间的区别感到困惑。本教程似乎意味着,每当我想使用ssh密钥时,我都需要输入一个密码,为了阻止这种情况,我需要以某种方式将密钥交给ssh代理。但是,在运行命令ssh-add并根据手册页运行之前,不会提示我输入密码。
ssh-add将RSA或DSA标识添加到认证代理ssh- agent (1)中.
如果代理的目的是不必使用密码,为什么代理要求我创建密码?
下面是我正在运行的代码以及我对ssh-add的理解:
ssh-keygen -t rsa -C "your_email@example.com"
# Creates a new ssh key, using the provided email as a label
# Generating public/private rsa key pair. Public key is like a padlock, private key is like a padlock key.
# Enter file in which to save the key (/Users/you/.ssh/id_rsa): [Press enter]
#This is like taking the padlock and they key together and sticking them in a box.
#-------------------------------
ssh-add id_rsa
#ssh-add is like sticking your key in a safe. Instead of putting your keys on a hook in your house, where anyone can pick it up, you put your key in a safe protected by a password.
Enter passphrase (empty for no passphrase): [Type a passphrase]
Enter same passphrase again: [Type passphrase again]
#The safe now has a password. ssh-add和ssh-agent之间的关系是什么?我是否正确地假设了以下几点:
发布于 2014-03-08 17:53:17
假设您有几台Linux机器要管理,并且通过创建一个公共私钥对(发出ssh-keygen -t rsa )来设置ssh登录。假设在创建密钥时没有设置密码。现在,您将通过发出ssh-copy-id -i ~/.ssh/id_rsa.pub user@somehost将您的公钥复制到您想要登录的所有机器。现在,使用您的密钥,您将能够登录到您复制您的密钥的所有机器。
由于您没有创建密码,任何获得您的私钥的人都可以登录到添加您的公钥的所有机器。假设你让你的机器被你的一些朋友使用,而他中的一个是邪恶的。为了防止这种情况,您可以将密码设置为私钥。因此,每当您使用密钥登录时,系统都会提示您输入密码,因此只有您(谁知道密码)才能登录。
但是,每当您登录到其他机器时,输入密码就变得非常麻烦。因此,您可以将您的密码提供给ssh-agent一次,并且它将在需要时使用它。您可以使用ssh-add将您的密钥交给ssh-agent。您可以始终通过发出ssh-agent来检查您的ssh-add -l正在管理的所有密钥。
https://stackoverflow.com/questions/22272299
复制相似问题