这些天,当我在设置页面上的GitHub上创建一个新的存储库时,我得到:
git remote add origin https://github.com/nikhilbhardwaj/abc.git
git push -u origin master
Run Code Online (Sandbox Code Playgroud)
每当我必须提交提交时,我需要输入我的GitHub用户名和密码.
我可以手动将其更改为
git@github.com:nikhilbhardwaj/abc.git
Run Code Online (Sandbox Code Playgroud)
在.git/config.我觉得这很烦人 - 有什么办法可以配置git默认使用SSH吗?
我正在使用git bash.我必须使用
eval `ssh-agent.exe`
ssh-add /my/ssh/location/
Run Code Online (Sandbox Code Playgroud)
每当我开始新的git bash时.
有没有办法永久设置ssh代理?或者Windows有一个很好的方法来管理ssh密钥?
我是新手,请给我详细的教程,谢谢!
问题: 如何在Windows命令提示符下使用ssh和scp?
我记得我过去安装了一个程序让我这样做但现在不记得是什么了.
注意: 我不想使用putty.
我正在尝试将生成的密钥添加到 ssh 代理。下面是我的步骤
C:\repo>ssh-keygen
Generating public/private rsa key pair.
Enter file in which to save the key (C:\Users\mante1/.ssh/id_rsa):C:\repo\key
Run Code Online (Sandbox Code Playgroud)
生成密钥后,我将启动 ssh 代理并添加它
C:\repo>start-ssh-agent
Found ssh-agent at 13460
Found ssh-agent socket at /tmp/ssh-vKzdrs37QYVK/agent.821
C:\repo>ssh-add ~/.ssh/id_rsa
Error connecting to agent: No such file or directory
Run Code Online (Sandbox Code Playgroud) 当我尝试通过PowerShell在Windows 10上启动ssh-agent(右侧或不右侧),输入Start-Service ssh-agent我得到错误
无法启动ssh-agent服务,错误:1058
当我检查服务正在运行时,Get-Service ssh-agent返回该服务已停止.
如何让ssh-agent运行?
我已经阅读了Tim Davis提供的优秀指南,该指南是关于将Git配置为在Windows下使用SSH以生成Git服务器以便为我的DVCS提供主要位置.
我正在为我的项目创建一个克隆.到目前为止,我已经完成了所有步骤,但我不断从TortoiseGit获取此信息:
git.exe clone -v “ssh://Administrator@127.0.0.1:22/SSH/Home/administrator/myapp.git” “E:\GitTest\myapp”
bash: Administrator@127.0.0.1: command not found
Initialized empty Git repository in E:/GitTest/myapp/.git/
fatal: The remote end hung up unexpectedly
Success
Run Code Online (Sandbox Code Playgroud)
没有任何东西被克隆.
BTW:TortoisePLink在此消息出现之前出现并询问我:" login as:"(我认为此信息在命令中给出,即:Administrator@blahblah.
我的home变量设置为正确的位置:从Git Bash shell:
echo $HOME
/c/SSH/home/Administrator
Run Code Online (Sandbox Code Playgroud)
我也尝试过使用Putty的plink代替TortoisePLink(在Git和TortoiseGit安装中).这次错误被缩小到:
git.exe clone -v “ssh://Administrator@127.0.0.1:22/c:/SSH/Home/administrator/myapp.git” “E:\GitTest\myapp”
Initialized empty Git repository in E:/GitTest/myapp/.git/
fatal: The remote end hung up unexpectedly
Run Code Online (Sandbox Code Playgroud) PS 5.1 中是否可以重用PuTTY 代理密钥?
现在,细节。
要使用密钥代理,有一个持有密钥的代理(左框)和委托管理密钥的客户端应用程序(右框)。例如,客户端应用程序 C1=putty可以使用它自己的代理 A1= pageant,当然。客户端应用程序 C2=winscp知道如何直接使用 A1。
某些客户端不能直接使用某些代理,但有代理代理可以弥补这一差距。例如,要将 A1 与 C3 一起使用,我需要 Proxy P1= ssh-pageant,请参见下面的示例。这有助于将许多客户端的密钥集中在单个代理中。现在我的意思是对我所有的客户使用 A1(目前,只缺少 A1-C5 和 A1-C6)。
PS 5.1 中是否可以重用相同的 PuTTY 代理密钥? (即,使用 A1 和 C5 的代理 Px)
可能有帮助:https : //superuser.com/a/1173570/245595
注意事项:
我没有尝试过,但似乎winssh-pageant是将 A2 与直接理解 A1 的客户端应用程序链接起来的代理。
我目前正在尝试在 PS 中使用与ssh-pageantmsys2相同的内容(它最终是一个 Windows 程序,而且它们经常工作),手动替换evalmsys2 中的内容(到目前为止没有运气,但我认为这是可以修复的) :
> cd <dir where ssh-pageant is>
> …Run Code Online (Sandbox Code Playgroud) 我在 Windows 上的 PowerShell 中使用 git。我确保ssh-agent正在运行,并且ssh-add有我的私钥。
$ Get-Service ssh-agent
Status Name DisplayName
------ ---- -----------
Running ssh-agent OpenSSH Authentication Agent
$ ssh-add -l
256 SHA256:2MDH36ZZcM1uf9wQ2tsMj4NROkiGeKUD+CwBsVXrKXY xxxxxxxxxx@gmail.com (ED25519)
Run Code Online (Sandbox Code Playgroud)
但 git 每次仍然要求输入密码。我尝试通过设置进行调试GIT_SSH_COMMAND="ssh -vvv",但无法理解出了什么问题。下面是我运行时的详细输出git push。
$ git push
OpenSSH_8.5p1, OpenSSL 1.1.1k 25 Mar 2021
debug1: Reading configuration data /etc/ssh/ssh_config
debug3: expanded UserKnownHostsFile '~/.ssh/known_hosts' -> '/c/Users/username/.ssh/known_hosts'
debug3: expanded UserKnownHostsFile '~/.ssh/known_hosts2' -> '/c/Users/username/.ssh/known_hosts2'
debug2: resolving "github.com" port 22
debug3: ssh_connect_direct: entering
debug1: Connecting to github.com [140.82.114.4] port …Run Code Online (Sandbox Code Playgroud) 因此,我遵循了有关如何使用 Windows CMD 为 github 设置 SSH 的教程,一切都工作正常,直到我使用以下命令克隆存储库
git clone git@github.com:{myusername}/{myrepo}.git
Run Code Online (Sandbox Code Playgroud)
我从哪里得到
git@github.com: Permission denied (publickey).
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
Run Code Online (Sandbox Code Playgroud)
即使当我运行时ssh -T git@github.com,我也会收到预期的消息,告诉我我已通过身份验证。
绞尽脑汁后,我决定在 git bash 上尝试一下。
我注意到的第一件事是跑步
ssh-add -l
Run Code Online (Sandbox Code Playgroud)
在 git bash 中,我得到了The agent has no identities.,但是当我在 Windows CMD 上运行相同的命令时,我得到了所有 SSH 密钥?
因此,在 git bash 中添加 ssh 密钥后,我能够克隆我的存储库。
那么,为什么我只能在 git bash 上执行此操作,而不能在 cmd 或 powershell 上执行此操作?这是否与他们使用不同的 ssh …