git - 在 Windows 上使用 SSH 私钥进行 Git 推送
问题描述
在这些命令之后,
git remote add origin server:<repo>.git
git push origin master
我需要输入密码。但我只想使用我的私有 ssh 密钥对服务器进行身份验证。例如,我可以使用该私钥连接到服务器,但我不知道如何使用它推送 git 存储库。
我的公钥 ofc 被添加到服务器上的授权密钥中。
解决方案
Your server need to support ssh or gitosis in order to do it. Gitosis:
In your cae you mentioned that you do have ssh connection so you simply have to set the remote with the ssh protocol
git remote set-url origin ssh://......
# or
git remote set-url origin git@...
how to configure ssh key path for git
- Open a terminal window.
- Edit the
~/.ssh/config
file. - If you don't have a config file, create one.
Add an alias for each identity combination for example:
Host <Host Name> HostName AAAAAAA.org IdentityFile ~/.ssh/<key for the given host> Host <Host1 Name> HostName BBBBB.org IdentityFile ~/.ssh/<host 2 key>
推荐阅读
- android - Android Firebase 和 Appmetrica 冲突
- java - 如何在逗号后反转字符串,然后打印字符串 Java 的前半部分
- hdfs - hdfs 快照是否适用于附加数据?
- visual-studio - 一个 VSTS 项目可以映射到不同的本地工作空间吗?
- excel - 使用 VBA Find 函数检查 Excel 工作表上是否已存在范围
- javascript - 在 Angular 2 中获取 GPS 源信息
- python - 从 setup.py 中查找 boost_python 版本
- selenium - 如何在机器人框架 RIDE 上运行录制的自动化脚本
- ms-access - 错误:SharePoint/Access 链接列表中的“找不到字段”
- django - 登录后根据用户组重定向