我家里的.ssh文件夹里有一堆钥匙。 如果我尝试使用下面的方法login到ec2实例
ssh -2 -vvvv -i ~/.ec2/boogoo.pem [email protected]
我在debugging输出中看到:
debug1: Authentications that can continue: publickey debug3: start over, passed a different list publickey debug3: preferred gssapi-keyex,gssapi-with-mic,publickey,keyboard-interactive,password debug3: authmethod_lookup publickey debug3: remaining preferred: keyboard-interactive,password debug3: authmethod_is_enabled publickey debug1: Next authentication method: publickey debug1: Offering RSA public key: abhi@panini
我看到一堆键试图这样,直到服务器禁止ssh尝试与消息
Too many authentication failures
现在,如果我删除了我的.ssh文件夹,在“debug1:Authentications that can continue:publickey”之后尝试的第一个键是boogoo.pem键,我可以login到服务器。
我很困惑,为什么这个behvaiour? 不应该-i开关清楚地告诉ssh客户端,boogoo.pem是它应该先尝试的关键,而不是尝试所有在.ssh文件夹中存在的其他关键字?
向命令行添加-o "IdentitiesOnly yes" ,或将IdentitiesOnly yes添加到~/.ssh/config的相应部分。
默认情况下, ssh提供~/.ssh默认位置的所有密钥以及身份validation代理向远程系统所表示的所有身份,如果您的密钥过多,远程系统可能会将您踢出失败。 启用IdentitiesOnly选项指定只应提供明确configuration的身份,这解决了问题。
请参阅SuperUser上的这个答案 。