通过 ssh 将 EC2 连接到 Git
Connect EC2 to Git by ssh
有一个带有 Git 存储库的 EC2 实例,我需要在 ssh-key
之前更新它。
我试过了:
将 authorized_keys
添加到 Git 中心。 --> 不工作而且方法不对。
创建一个新的 ssh-key,将其添加到 EC2 控制台 pair-key 并添加到 GitHub。由于 ssh-add 在 EC2 实例上不工作,@Biswajit Mohanty 建议我 运行 ssh -T git@github.com,并得到了正确的答案,但仍然得到 'permission denied (publickey). fatal: could not read from remote repository'拉.
我已经按照应有的方式配置了 .git/config:
sshCommand = "ssh -i ~/.ssh/id_rsa.pub"
[远程“来源”]
url = ssh://git@github.com/ArantecEnginheria/smartyplanet.git
关于成功执行 'pull' 并将代码更新到该服务器的任何建议?
您通常不会将 authorized_keys
添加到 GitHub。您register a public SSH key to your GitHub user profile,以便建立正确的身份验证。
如果您需要从 EC2 实例推送到 GitHub 存储库(意味着从 EC2 instance session),则所述会话应包含 ~/.ssh/id_rsa
和 ~/.ssh/id_rsa.pub
: private/public 密钥对,其中 public 一个注册到 GitHub 如上所述。
ssh-keygen -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/c/Users/.ssh/id_rsa): ./yourgitkey
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in ./yourgitkey
Your public key has been saved in ./yourgitkey.pub
将./yourgitkey.pub的内容复制到GitHubhttps://github.com/settings/keys
添加新的 SSH 密钥并输入 ./yourgitkey.pub
为避免权限错误:
让你的私钥权限
chmod 400 ./yourgitkey
输入以下内容:
$ ssh -T git@github.com
您可能会看到这样的警告:
> The authenticity of host 'github.com (IP ADDRESS)' can't be established.
> RSA key fingerprint is SHA256:nThbg6kXUpJWGl7E1IGOCspRomTxdCARLviKw6E5SY8.
> Are you sure you want to continue connecting (yes/no)?
Verify that the fingerprint in the message you see matches GitHub's RSA public key fingerprint.
如果是,则输入是:
Hi username! You've successfully authenticated, but GitHub does not
provide shell access.
你现在准备好了!!!
有一个带有 Git 存储库的 EC2 实例,我需要在 ssh-key
之前更新它。
我试过了:
将
authorized_keys
添加到 Git 中心。 --> 不工作而且方法不对。创建一个新的 ssh-key,将其添加到 EC2 控制台 pair-key 并添加到 GitHub。由于 ssh-add 在 EC2 实例上不工作,@Biswajit Mohanty 建议我 运行 ssh -T git@github.com,并得到了正确的答案,但仍然得到 'permission denied (publickey). fatal: could not read from remote repository'拉.
我已经按照应有的方式配置了 .git/config:
sshCommand = "ssh -i ~/.ssh/id_rsa.pub"
[远程“来源”] url = ssh://git@github.com/ArantecEnginheria/smartyplanet.git
关于成功执行 'pull' 并将代码更新到该服务器的任何建议?
您通常不会将 authorized_keys
添加到 GitHub。您register a public SSH key to your GitHub user profile,以便建立正确的身份验证。
如果您需要从 EC2 实例推送到 GitHub 存储库(意味着从 EC2 instance session),则所述会话应包含 ~/.ssh/id_rsa
和 ~/.ssh/id_rsa.pub
: private/public 密钥对,其中 public 一个注册到 GitHub 如上所述。
ssh-keygen -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/c/Users/.ssh/id_rsa): ./yourgitkey
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in ./yourgitkey
Your public key has been saved in ./yourgitkey.pub
将./yourgitkey.pub的内容复制到GitHubhttps://github.com/settings/keys
添加新的 SSH 密钥并输入 ./yourgitkey.pub
为避免权限错误: 让你的私钥权限
chmod 400 ./yourgitkey
输入以下内容:
$ ssh -T git@github.com
您可能会看到这样的警告:
> The authenticity of host 'github.com (IP ADDRESS)' can't be established.
> RSA key fingerprint is SHA256:nThbg6kXUpJWGl7E1IGOCspRomTxdCARLviKw6E5SY8.
> Are you sure you want to continue connecting (yes/no)?
Verify that the fingerprint in the message you see matches GitHub's RSA public key fingerprint.
如果是,则输入是:
Hi username! You've successfully authenticated, but GitHub does not provide shell access.
你现在准备好了!!!