如何告诉git不要使用rsa密钥而是使用用户名+密码

mcE*_*nge 3 server ssh password git

我想我的 ssh 配置搞乱了。

最近我无法再克隆本地存储库。git 存储库似乎同时接受公钥和密码,但它没有让我选择这两个选项之一,而是尝试使用一些错误的 RSA 密钥进行连接,导致出现以下消息:

Received disconnect from myRemoteComputer : Too many authentication failures for myUsername
fatal: Could not read from remote repository.
Run Code Online (Sandbox Code Playgroud)

当我 ssh 到那台计算机时也会发生同样的情况

$ssh -v myRemoteComputerIP
debug1: Authentications that can continue: publickey,password
debug1: Next authentication method: publickey
debug1: Offering RSA public key: /home/myUsername/.ssh/id_rsa
debug1: Authentications that can continue: publickey,password
debug1: Offering RSA public key: myUsername@cvg04
Received disconnect from myRemoteComputerIP: Too many authentication failures for myUsername
Run Code Online (Sandbox Code Playgroud)

所以出了问题,因为最近两个命令都正常工作。我基本上需要告诉sshgit使用用户名和密码,而不是随机选择错误的“RSA 密钥”。有谁知道如何修复这个?

ssh-add最近还按照一些论坛建议执行了一些命令,但也许这是问题的一部分......

Jak*_*uje 5

检查你的~/.ssh/config。如果你想使用密码验证,你可以像这样设置:

Host myRemoteComputerIP
  PubkeyAuthentication no
Run Code Online (Sandbox Code Playgroud)

它永远不会尝试针对该主机进行公钥身份验证。


当我必须使用 rsa 密钥和另一个用户名/密码身份验证连接两个不同的用户名时怎么样?

您可以在以下位置使用别名ssh_config

Host alias1
  Hostname myRemoteComputerIP
  PubkeyAuthentication no
  User user1
Host alias2
  Hostname myRemoteComputerIP
  # PubkeyAuthentication yes # is default
  User user2
Run Code Online (Sandbox Code Playgroud)

然后使用ssh alias1和连接ssh alias2