将Jar文件上传到AWS EC2实例时,使用scp出现权限被拒绝的错误。

0

【以下的问题经过翻译处理】 我使用ssh ec2-user@MY_IP连接到服务器成功后,安装了Java。

但是当我尝试使用scp上传JAR文件时,出现以下错误:

ED25519 key fingerprint is SHA256:XXXXXXXXXXX.
This key is not known by any other names
Are you sure you want to continue connecting (yes/no/[fingerprint])?

当我点击"yes"时,我会得到以下错误:

Permission denied (publickey,gssapi-keyex,gssapi-with-mic).
Connection closed

我已经将我的公钥添加为"导入密钥对",这意味着我没有.pem文件。

我该怎么办?如何将文件上传到服务器?为什么会出现这个错误,尽管使用ssh连接到服务器的连接工作正常。

我使用以下命令进行连接:

ssh ec2-user@MY_PUBLIC_IP

然后我尝试使用以下命令上传JAR:

scp build/libs/app.jar ec2-user@MY_PUBLIC_IP:/home/ec2-user

然后出现错误。

profile picture
EXPERT
asked 5 months ago29 views
1 Answer
0

【以下的回答经过翻译处理】 我认为问题出在语法上。首先,你不需要通过ssh登录到终端中,再运行SCP命令。确保你是在本地运行。

在SCP命令中,确保远程路径以/结尾。

scp build/libs/app.jar ec2-user@MY_PUBLIC_IP:/home/ec2-user/

就应该可以了。

profile picture
EXPERT
answered 5 months ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions