首页 > 解决方案 > 如何将提交更改推送到 aws 远程服务器实例?

问题描述

我已经按照这些说明https://alphacoder.xyz/git-push-to-an-aws-ec2-remote-using-a-pem-file/。但它不起作用。

标签: gitamazon-web-servicesgitlab

解决方案


最新的官方说明是Amazon Elastic Compute Cloud 上的“使用 SSH 客户端连接到您的 Linux 实例”。
这可能比 2017 年的帖子更可靠。

不要忘记在第一次连接时回答是(ssh -i /path/my-key-pair.pem my-instance-user-name@my-instance-public-dns-name):

The authenticity of host 'ec2-198-51-100-1.compute-1.amazonaws.com (198-51-100-1)' can't be established.
ECDSA key fingerprint is l4UB/neBad9tvkgJf1QZWxheQmR59WgrgzEimCG6kZY.
Are you sure you want to continue connecting (yes/no)?

(yes)

Warning: Permanently added 'ec2-198-51-100-1.compute-1.amazonaws.com' (ECDSA) to the list of known hosts.

连接后,您需要生成一组不同的 SSH 密钥,以便将公共密钥注册到您的 GitLab 帐户,并在该实例上克隆 GitLab 存储库。
请参阅“ GitLab 和 SSH 密钥”。


我在带有 ssh 的 aws 实例远程服务器上有一个项目。我使用这个实例 ssh 将该项目下载到我的本地

如果您在本地复制 (scp) 远程 AWS 项目,您最终会得到 AWS .git 存储库及其设置,因此是远程 GitLab。

您需要在本地生成一个新的 ssh 密钥,将其注册到您的 GitLab 帐户,并在能够推送回 GitLab 之前使用它。


推荐阅读