简体   繁体   English

如果我使用 https 连接到存储库,如何使用 SSH 密钥?

[英]How is it possible to use SSH key if I connect to a repository using https?

The company firewall does only allow https connection to github.com ( no ssh ), so I added the repository like this:公司防火墙只允许 https 连接到 github.com(没有 Z1787D7646304C5D987777CFE)

git remote add origin https://github.com/myProject.git

Unfortunately if I call git push , github asks for my username and password.不幸的是,如果我调用git push , github 会询问我的用户名和密码。 I already created an ssh key using ssh-keygen .我已经使用ssh-keygen创建了一个 ssh 密钥。

How is it possible to use SSH keys with a https repository?如何将 SSH 密钥与 https 存储库一起使用?


I tried SSh over HTTPS :我在 HTTPS 上尝试了 SSh

ssh -T -p 443 git@ssh.github.com

But I get this error:但我得到这个错误:

ssh: connect to host ssh.github.com port 443: Connection refused

The error is supposedly because ssh.github.com is a dedicated server (I think several of them, and it resolves to the two distinct IP addresses presently), and your company's firewall supposedly only whitelists connections to "basic" github.com which resolves to a set of hosts different to those of ssh.github.com . The error is supposedly because ssh.github.com is a dedicated server (I think several of them, and it resolves to the two distinct IP addresses presently), and your company's firewall supposedly only whitelists connections to "basic" github.com which resolves到一组不同于ssh.github.com的主机。
This is needed because in both cases the server-side software handling incoming connections on the same port has to be different (an SSH server versus a web server speaking HTTPS).这是必需的,因为在这两种情况下,处理同一端口上的传入连接的服务器端软件必须不同(SSH 服务器与 web 服务器使用 HTTPS)。

As to your general question — no, this is not possible: SSH (the S ecure SH ell protocol and H yper T ext T ransfer P rotocol, S ecure) bear no relation to each other except for the fact they both provide security (authentication and confidentiality) for the communication channels they manage.至于您的一般问题-不,这是不可能的: SSH (安全SH ell协议和超文本传输协议,安全)彼此没有任何关系,除了它们都提供安全性(身份验证和机密性)用于他们管理的通信渠道。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在github https存储库地址上使用git和ssh? - How to use git with ssh on github https repository addresses? Gitlab:无法使用 SSH 密钥或 HTTPS 连接 - Gitlab: unable to connect with SSH key or HTTPS 如何使用不同的 SSH 密钥在 CircleCI 中克隆第二个 GitHub 存储库(作为主克隆或作为子模块)? - How can I use a different SSH key to clone a second GitHub repository in CircleCI (either as the main clone or as a submodule)? git 克隆无法使用错误“要访问此存储库,您必须使用带有个人访问令牌的 HTTPS 遥控器或带有 SSH 密钥的 SSH” - git clone not working with error " To access this repository, you must use the HTTPS remote with a personal access token or SSH with an SSH key" 如何使用带密码的 SSH 密钥使用 GitPython 克隆 git 存储库 - How to clone git repository with GitPython using SSH key with passphrase 是否可以在2台机器上使用相同的ssh私钥/公钥对来访问git存储库? - Is it possible to use the same ssh private/public key pair on 2 machines to access a git repository? 如何使用带有 ssh 密钥的 GitPython? - How do I use GitPython with a ssh key? 如何使用SSH将存储库推送到GitHub? - How can I use SSH to push my repository to GitHub? 我在存储库中发布了私有SSH密钥 - I published my private SSH key in a repository 尽管仅提供ssh访问,但仍使用https访问git存储库 - Accessing a git repository using https, despite it providing ssh access only
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM