scp를 사용하여 파일을 Amazon EC2 인스턴스에 복사합니까?
Mac 터미널을 사용하여 다운로드 (온라인으로 다운로드 한 phpMyAdmin)에서 Amazon EC2 인스턴스로 파일을 scp하려고합니다.
내가 사용한 명령은 다음과 같습니다.
scp -i myAmazonKey.pem phpMyAdmin-3.4.5-all-languages.tar.gz hk22@mec2-50-17-16-67.compute-1.amazonaws.com:~/.
내가 얻은 오류 : 경고 : ID 파일 myAmazonKey.pem에 액세스 할 수 없음 : 해당 파일이나 디렉토리가 없습니다. 권한이 거부되었습니다 (공개 키). 연결이 끊어짐
myAmazonkey.pem과 phpMyAdmin-3.4.5-all-languages.tar.gz가 모두 다운로드에 있으므로 시도했습니다.
scp -i /Users/Hello_Kitty22/Downloads/myAmazonKey.pem /Users/Hello_Kitty22/Downloads/phpMyAdmin-3.4.5-all-languages.tar.gz hk22@mec2-50-17-16-67.compute-1.amazonaws.com:~/.
그리고 내가 얻은 오류 : 경고 : 신원 파일 /User/Hello_Kitty22/Downloads/myAmazonkey.pem 액세스 할 수 없음 : 해당 파일이나 디렉토리가 없습니다. 권한이 거부되었습니다 (공개 키). 연결이 끊어짐
누구든지 내 문제를 해결하는 방법을 알려주십시오.
추신 비슷한 게시물이 있습니다 : 비밀번호없이 ec2 인스턴스에 scp (보안 사본) 이지만 내 질문에 대답하지 않습니다.
ec2-user
예를 들어 사용자를 다음 과 같이 지정하십시오.
scp -i myAmazonKey.pem phpMyAdmin-3.4.5-all-languages.tar.gz ec2-user@mec2-50-17-16-67.compute-1.amazonaws.com:~/.
SSH를 사용하여 Linux / UNIX 인스턴스에 연결을 참조하십시오 .
두 번째 디렉토리는 대상 위치이므로 서버 이름을 사용하지 마십시오. 즉, 현재있는 컴퓨터의 컴퓨터 이름을 언급 할 필요가 없습니다.
scp -i /path/to/your/.pemkey -r /copy/from/path user@server:/copy/to/path
디렉토리 인 경우 -r
SSH가 작동하려면 키를 공개적으로 볼 수 없어야합니다. 필요한 경우이 명령을 사용하십시오.
chmod 400 yourPublicKeyFile.pem
위의 scp 명령을 시도하려면 로컬 시스템에 있어야합니다.
로컬 컴퓨터에서 다음을 시도하십시오.
scp -i ~/Downloads/myAmazonKey.pem ~/Downloads/phpMyAdmin-3.4.5-all-languages.tar.gz hk22@mec2-50-17-16-67.compute-1.amazonaws.com:~/.
EC2 인스턴스에 적용되는 세부 사항은 다음과 같습니다 .
scp -i /path/to/whatever.pem /users/me/path-to-file ec2-user@ec2-55-55-555-555.compute-1.amazonaws.com:~
몇 가지 참고 사항 :
- 다음에 주어진 세 매개 변수 사이의 공백에 유의하십시오.
-i
scp
보안 복사 프로토콜을 나타냅니다. 단어를 알면 명령을 더 쉽게 기억할 수 있습니다.-i
.pem
파일을 다음 매개 변수로 제공해야 함을 나타냅니다 . 더가있는 경우-i
, 당신은 필요 없어보다.pem
.:~
EC2 인스턴스의 대상 끝 부분에 유의하십시오 .
나는 똑같은 문제를 겪었다.
scp -i /path/pem -r /path/file/ ec2-user@public aws dns name:
(여기서 비워 두십시오)
이 부분을 완료하면 ssh 서버와 mv 파일을 원하는 위치로 가져갑니다.
scp -i ~/path to pem file/file.pem -r(for directory) /PATH OF LOCAL/localfile user@hostname:PATH OF SERVER/serverdirectory
아래 SCP 형식은 저에게 효과적입니다.
scp -i /path/my-key-pair.pem ec2-user@ec2-198-51-100-1.compute-1.amazonaws.com:~/SampleFile.txt ~/SampleFile2.txt
SampleFile.txt : 루트 디렉토리 (내 경우에는 / home / ubuntu)의 경로가됩니다. 내 경우에는 다운로드하려는 파일이 / var / www에 있습니다.
SampleFile2.txt : 컴퓨터의 루트 경로 (내 경우에는 / home / MyPCUserName)가됩니다.
그래서 아래 명령을 작성해야합니다
scp -i /path/my-key-pair.pem ec2-user@ec2-198-51-100-1.compute-1.amazonaws.com:~/../../var/www/Filename.zip ~/Downloads
로컬에서 서버로 파일 보내기 :
scp -i .ssh / awsinstance.pem my_local_file ubuntu@XX.XXX.XXX.XXX : / home / ubuntu
서버에서 로컬로 파일 다운로드 :
scp -i .ssh / awsinstance.pem ubuntu@XX.XXX.XXX.XXX : / home / ubuntu / server_file
AWS EC2 리눅스 인스턴스에 대한 로컬 시스템에서 파일을 복사 SCP를 사용하는 과정을 단계별로에 (포인트 후술 포함) 피복 동영상 .
SCP 사용과 관련된이 특정 문제를 해결하려면 :
올바른 Linux 사용자를 지정해야합니다. 에서 아마존 :
- Amazon Linux의 경우 사용자 이름은 ec2-user입니다.
- RHEL의 경우 사용자 이름은 ec2-user 또는 root입니다.
- 우분투의 경우 사용자 이름은 우분투 또는 루트입니다.
- Centos의 경우 사용자 이름은 centos입니다.
- Fedora의 경우 사용자 이름은 ec2-user입니다.
- SUSE의 경우 사용자 이름은 ec2-user 또는 root입니다.
- 그렇지 않으면 ec2-user 및 root가 작동하지 않으면 AMI 공급자에게 문의하십시오.
Your private key must not be publicly visible. Run the following command so that only the root user can read the file.
chmod 400 /path/to/yourKeyFile.pem
Check the permissions on the .pem file...openssh usually doesn't like world-readable private keys, and will fail (iir, scp doesn't do a great job of providing this feedback to the user).
Can you simply ssh with that key to your AWS host?
First you should change the mode of .pem
file from read and write mode to read only mode. This can be done just by a single command in terminal sudo chmod 400 your_public_key.pem
I tried all the suggestions mentioned above and nothing worked. I terminated the current instance, launched another one and repeated the same exact process. This time no problems. Sometimes it might be the remote ami's fault.
I would use:
scp -i "path to .pem file" "file to be copeide from local machine" username@amazoninstance: 'destination folder to copy file on remote machine'
참고URL : https://stackoverflow.com/questions/11388014/using-scp-to-copy-a-file-to-amazon-ec2-instance
'Programing' 카테고리의 다른 글
Java 주석의 / ** 및 / * (0) | 2020.05.20 |
---|---|
한 목록에서 다른 목록의 항목 제거 (0) | 2020.05.20 |
단항 연산자 예상 (0) | 2020.05.20 |
스위프트-절대 값으로 변환 (0) | 2020.05.20 |
Makefile의 현재 상대 디렉토리를 얻는 방법? (0) | 2020.05.20 |