I have tried to SSH into my AWS Ubuntu server and copy the directory to my local machine. Throughout the process I experience different file permission errors (noted below).
Is there one specific file permission needed for the .pem file that allows me to SSH and SCP?
Or do I need to change the file permission twice - once for SSH and another for SCP after I login?
Here are the commands I'm using:
SSH:
ssh -i sentiment.pem [email protected]
Copy from remote to local computer with:
scp [email protected]:/home/ubuntu/sentimentfolder /Users/Toga/Desktop/sentimentlocal
I'm on a Mac OS X 10.7.5.
Trial and Error:
After I initially downloaded the .pem file, its permissions were set to, I THINK: 0644
-rw-r--r--@ 1 Toga staff 1692 Feb 18 21:27 sentiment.pem
I then tried to SSH via terminal and received the following:
WARNING: UNPROTECTED PRIVATE KEY FILE! Permissions 0644 for 'sentiment.pem' are too open. It is recommended that your private key files are NOT accessible by others. This private key will be ignored. bad permissions: ignore key: sentiment.pem Permission denied (publickey).
I updated the file permissions to:
chmod 660 sentiment.pem
After the update, the permissions were set to:
-rw-rw----@ 1 Toga staff 1692 Feb 18 21:27 sentiment.pem
I then tried to SSH via terminal and received the following:
WARNING: UNPROTECTED PRIVATE KEY FILE! Permissions 0660 for 'sentiment.pem' are too open. It is recommended that your private key files are NOT accessible by others. This private key will be ignored. bad permissions: ignore key: sentiment.pem Permission denied (publickey).
I updated the file permissions to:
chmod 600 sentiment.pem
After the update, the permissions were set to:
-rw-------@ 1 Toga staff 1692 Feb 18 21:27 sentiment.pem
I then tried to SSH via terminal and was successful!!
Now logged in, I run the a command to copy the remote directory to my local computer with:
scp [email protected]:/home/ubuntu/sentimentfolder /Users/Toga/Desktop/sentimentlocal
Which returns:
Permission denied (publickey).
SCP Commands Attempted:
added the option
-i
and referenced the.pem
file:scp -i sentiment.pem [email protected]:/home/ubuntu/sentimentfolder /Users/Toga/Desktop/sentimentlocal
added the option
-i
, referenced the.pem
file, and changed the user for AWS toec2-user
:scp -i sentiment.pem [email protected]:/home/ubuntu/sentimentfolder /Users/Toga/Desktop/sentimentlocal
added the option
-i
, referenced the.pem
file, changed the user for AWS toec2-user
, and added the complete file path for the location of the.pem
file:scp -i /Users/Toga/Desktop/rollup/Personal/Serial_Project_Starter/sentiment/sentiment.pem [email protected]:/home/ubuntu/sentiment /Users/Toga/Desktop/sentimentlocal