Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
266 views
in Technique[技术] by (71.8m points)

amazon web services - scp "connection lost" when transferring files from Mac to ec2

I have created a EC2 instance and is trying to launch a flask api (with tensorflow) on it.

I am currently trying to transfer files over from my Mac to the EC2 instance, but keep getting the following error...

Connection closed by 100.26.246.133 port 22
lost connection

the scp command I am using is as follows.

scp -i /Users/joelleo/Desktop/Work/ICC:Computing/Projects:Events/SCSE/2021/others/ec2-no-restrictions.pem -r /Users/joelleo/Desktop/Work/ICC:Computing/Projects:Events/SCSE/2021/application/ ec2-100-26-246-133.compute-1.amazonaws.com:~/app/

I have doubled check all the file paths and it is correct. also I have managed to successfully ssh into the ec2 instance and also managed to use scp in the past before

ssh into ec2 instance..

(base) joelleo@Joels-MacBook-Air others % ssh -i "ec2-no-restrictions.pem" [email protected]
Welcome to Ubuntu 18.04.5 LTS (GNU/Linux 5.4.0-1029-aws x86_64)

 * Documentation:  https://help.ubuntu.com
 * Management:     https://landscape.canonical.com
 * Support:        https://ubuntu.com/advantage

  System information as of Wed Jan  6 16:44:00 UTC 2021

  System load:  0.0               Processes:           112
  Usage of /:   23.8% of 7.69GB   Users logged in:     0
  Memory usage: 1%                IP address for eth0: 172.31.54.61
  Swap usage:   0%


51 packages can be updated.
33 updates are security updates.

New release '20.04.1 LTS' available.
Run 'do-release-upgrade' to upgrade to it.


*** System restart required ***
Last login: Wed Jan  6 16:23:51 2021 from 115.66.136.180
ubuntu@ip-172-31-54-61:~$

I have also checked that I am opening the correct ports in ec2 instance.

inbound rules.. enter image description here

outbound rules.. enter image description here

I read online that scp works using ssh.. can someone help as to why I am unable to connect using scp now?

thks!


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

It seems, some network problem between ec2 and the scp client. Perform below steps

  1. Change internet connection and try again.
  2. Cross check ec2 security group on AWS.
  3. Perform scp -v verbose mode to identify why it is failing.

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...