Copy file from EC2 to local computer error: Warning: Identity file file.pem not accessible: No such file or...












0















I have an AWS EC2 instance with files inside. I would like to copy some files from EC2 to my local machine (mac).



I connect successfully in ssh using file.pem which is save to a hidden folder called .ssh in my mac:



macbook:~ name$ cd /Users/name/.ssh
macbook:.ssh name$ ls
file.pem known_hosts
macbook:.ssh name$ chmod 400 file.pem
macbook:.ssh name$ ssh ubuntu@ipEc2 -i file.pem


I use this command line in order to copy a file from EC2 to my local machine:



ubuntu@ip-address:~$ scp -i /Users/name/.ssh/file.pem ubuntu@ec2-ip-address.eu-west-1.compute.amazonaws.com:/var/www/html/folder/file_to_copy.jpeg /Users/name/Desktop/folder


But the system send me an warning message:



Warning: Identity file /Users/name/.ssh/file.pem not accessible: No such file or directory.
Permission denied (publickey).


Even if I try this :



scp -i /Users/name/.ssh/file.pem ubuntu@IP.address:/var/www/html/folder/file_to_copy.jpeg /Users/name/Desktop/folder


I have the same warning response. I don't understand why because file.pem exist in .ssh folder and I just used chmod 400 to protect my file.pem for overwriting.



I went through the internet in order to try to figure it out where does it come from but I didn't find something which work...



Thanks for your help :-)










share|improve this question























  • Looks like you're running scp from your Ubuntu while informing -i /Users/name/.ssh/file.pem, whose path only exists in your Mac. You have to copy the key to your Ubuntu if you want to use it there.

    – jweyrich
    Dec 28 '18 at 14:43











  • @jweyrich Thank you for your help. So if i understand well I have to copy my file.pem in ubuntu but is it safe? For example, if anyone could have access to my EC2 instance it could copy it and use it after... right?

    – Idriss
    Dec 28 '18 at 15:00











  • When you inform -i /path/to/pem to your scp/ssh command, you're telling it to read the private key from a local file. Local in the sense that the file must reside and be accessible by the instance/vm/machine you're running the command on. FWIW, you may have distinct keys for distinct instances and/or purposes if you wish.

    – jweyrich
    Dec 28 '18 at 15:18













  • @jweyrich thanks for your answer. I understand that is why i tested directly in my local command line the scp command with the -i /path/to/file.pem and it works! thank you very much!

    – Idriss
    Dec 28 '18 at 16:11


















0















I have an AWS EC2 instance with files inside. I would like to copy some files from EC2 to my local machine (mac).



I connect successfully in ssh using file.pem which is save to a hidden folder called .ssh in my mac:



macbook:~ name$ cd /Users/name/.ssh
macbook:.ssh name$ ls
file.pem known_hosts
macbook:.ssh name$ chmod 400 file.pem
macbook:.ssh name$ ssh ubuntu@ipEc2 -i file.pem


I use this command line in order to copy a file from EC2 to my local machine:



ubuntu@ip-address:~$ scp -i /Users/name/.ssh/file.pem ubuntu@ec2-ip-address.eu-west-1.compute.amazonaws.com:/var/www/html/folder/file_to_copy.jpeg /Users/name/Desktop/folder


But the system send me an warning message:



Warning: Identity file /Users/name/.ssh/file.pem not accessible: No such file or directory.
Permission denied (publickey).


Even if I try this :



scp -i /Users/name/.ssh/file.pem ubuntu@IP.address:/var/www/html/folder/file_to_copy.jpeg /Users/name/Desktop/folder


I have the same warning response. I don't understand why because file.pem exist in .ssh folder and I just used chmod 400 to protect my file.pem for overwriting.



I went through the internet in order to try to figure it out where does it come from but I didn't find something which work...



Thanks for your help :-)










share|improve this question























  • Looks like you're running scp from your Ubuntu while informing -i /Users/name/.ssh/file.pem, whose path only exists in your Mac. You have to copy the key to your Ubuntu if you want to use it there.

    – jweyrich
    Dec 28 '18 at 14:43











  • @jweyrich Thank you for your help. So if i understand well I have to copy my file.pem in ubuntu but is it safe? For example, if anyone could have access to my EC2 instance it could copy it and use it after... right?

    – Idriss
    Dec 28 '18 at 15:00











  • When you inform -i /path/to/pem to your scp/ssh command, you're telling it to read the private key from a local file. Local in the sense that the file must reside and be accessible by the instance/vm/machine you're running the command on. FWIW, you may have distinct keys for distinct instances and/or purposes if you wish.

    – jweyrich
    Dec 28 '18 at 15:18













  • @jweyrich thanks for your answer. I understand that is why i tested directly in my local command line the scp command with the -i /path/to/file.pem and it works! thank you very much!

    – Idriss
    Dec 28 '18 at 16:11
















0












0








0








I have an AWS EC2 instance with files inside. I would like to copy some files from EC2 to my local machine (mac).



I connect successfully in ssh using file.pem which is save to a hidden folder called .ssh in my mac:



macbook:~ name$ cd /Users/name/.ssh
macbook:.ssh name$ ls
file.pem known_hosts
macbook:.ssh name$ chmod 400 file.pem
macbook:.ssh name$ ssh ubuntu@ipEc2 -i file.pem


I use this command line in order to copy a file from EC2 to my local machine:



ubuntu@ip-address:~$ scp -i /Users/name/.ssh/file.pem ubuntu@ec2-ip-address.eu-west-1.compute.amazonaws.com:/var/www/html/folder/file_to_copy.jpeg /Users/name/Desktop/folder


But the system send me an warning message:



Warning: Identity file /Users/name/.ssh/file.pem not accessible: No such file or directory.
Permission denied (publickey).


Even if I try this :



scp -i /Users/name/.ssh/file.pem ubuntu@IP.address:/var/www/html/folder/file_to_copy.jpeg /Users/name/Desktop/folder


I have the same warning response. I don't understand why because file.pem exist in .ssh folder and I just used chmod 400 to protect my file.pem for overwriting.



I went through the internet in order to try to figure it out where does it come from but I didn't find something which work...



Thanks for your help :-)










share|improve this question














I have an AWS EC2 instance with files inside. I would like to copy some files from EC2 to my local machine (mac).



I connect successfully in ssh using file.pem which is save to a hidden folder called .ssh in my mac:



macbook:~ name$ cd /Users/name/.ssh
macbook:.ssh name$ ls
file.pem known_hosts
macbook:.ssh name$ chmod 400 file.pem
macbook:.ssh name$ ssh ubuntu@ipEc2 -i file.pem


I use this command line in order to copy a file from EC2 to my local machine:



ubuntu@ip-address:~$ scp -i /Users/name/.ssh/file.pem ubuntu@ec2-ip-address.eu-west-1.compute.amazonaws.com:/var/www/html/folder/file_to_copy.jpeg /Users/name/Desktop/folder


But the system send me an warning message:



Warning: Identity file /Users/name/.ssh/file.pem not accessible: No such file or directory.
Permission denied (publickey).


Even if I try this :



scp -i /Users/name/.ssh/file.pem ubuntu@IP.address:/var/www/html/folder/file_to_copy.jpeg /Users/name/Desktop/folder


I have the same warning response. I don't understand why because file.pem exist in .ssh folder and I just used chmod 400 to protect my file.pem for overwriting.



I went through the internet in order to try to figure it out where does it come from but I didn't find something which work...



Thanks for your help :-)







amazon-web-services amazon-ec2






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Dec 28 '18 at 14:37









IdrissIdriss

142




142













  • Looks like you're running scp from your Ubuntu while informing -i /Users/name/.ssh/file.pem, whose path only exists in your Mac. You have to copy the key to your Ubuntu if you want to use it there.

    – jweyrich
    Dec 28 '18 at 14:43











  • @jweyrich Thank you for your help. So if i understand well I have to copy my file.pem in ubuntu but is it safe? For example, if anyone could have access to my EC2 instance it could copy it and use it after... right?

    – Idriss
    Dec 28 '18 at 15:00











  • When you inform -i /path/to/pem to your scp/ssh command, you're telling it to read the private key from a local file. Local in the sense that the file must reside and be accessible by the instance/vm/machine you're running the command on. FWIW, you may have distinct keys for distinct instances and/or purposes if you wish.

    – jweyrich
    Dec 28 '18 at 15:18













  • @jweyrich thanks for your answer. I understand that is why i tested directly in my local command line the scp command with the -i /path/to/file.pem and it works! thank you very much!

    – Idriss
    Dec 28 '18 at 16:11





















  • Looks like you're running scp from your Ubuntu while informing -i /Users/name/.ssh/file.pem, whose path only exists in your Mac. You have to copy the key to your Ubuntu if you want to use it there.

    – jweyrich
    Dec 28 '18 at 14:43











  • @jweyrich Thank you for your help. So if i understand well I have to copy my file.pem in ubuntu but is it safe? For example, if anyone could have access to my EC2 instance it could copy it and use it after... right?

    – Idriss
    Dec 28 '18 at 15:00











  • When you inform -i /path/to/pem to your scp/ssh command, you're telling it to read the private key from a local file. Local in the sense that the file must reside and be accessible by the instance/vm/machine you're running the command on. FWIW, you may have distinct keys for distinct instances and/or purposes if you wish.

    – jweyrich
    Dec 28 '18 at 15:18













  • @jweyrich thanks for your answer. I understand that is why i tested directly in my local command line the scp command with the -i /path/to/file.pem and it works! thank you very much!

    – Idriss
    Dec 28 '18 at 16:11



















Looks like you're running scp from your Ubuntu while informing -i /Users/name/.ssh/file.pem, whose path only exists in your Mac. You have to copy the key to your Ubuntu if you want to use it there.

– jweyrich
Dec 28 '18 at 14:43





Looks like you're running scp from your Ubuntu while informing -i /Users/name/.ssh/file.pem, whose path only exists in your Mac. You have to copy the key to your Ubuntu if you want to use it there.

– jweyrich
Dec 28 '18 at 14:43













@jweyrich Thank you for your help. So if i understand well I have to copy my file.pem in ubuntu but is it safe? For example, if anyone could have access to my EC2 instance it could copy it and use it after... right?

– Idriss
Dec 28 '18 at 15:00





@jweyrich Thank you for your help. So if i understand well I have to copy my file.pem in ubuntu but is it safe? For example, if anyone could have access to my EC2 instance it could copy it and use it after... right?

– Idriss
Dec 28 '18 at 15:00













When you inform -i /path/to/pem to your scp/ssh command, you're telling it to read the private key from a local file. Local in the sense that the file must reside and be accessible by the instance/vm/machine you're running the command on. FWIW, you may have distinct keys for distinct instances and/or purposes if you wish.

– jweyrich
Dec 28 '18 at 15:18







When you inform -i /path/to/pem to your scp/ssh command, you're telling it to read the private key from a local file. Local in the sense that the file must reside and be accessible by the instance/vm/machine you're running the command on. FWIW, you may have distinct keys for distinct instances and/or purposes if you wish.

– jweyrich
Dec 28 '18 at 15:18















@jweyrich thanks for your answer. I understand that is why i tested directly in my local command line the scp command with the -i /path/to/file.pem and it works! thank you very much!

– Idriss
Dec 28 '18 at 16:11







@jweyrich thanks for your answer. I understand that is why i tested directly in my local command line the scp command with the -i /path/to/file.pem and it works! thank you very much!

– Idriss
Dec 28 '18 at 16:11














1 Answer
1






active

oldest

votes


















1














I found the answer !



When I wanted to copy a file from an AWS EC2 instance to my local machine (mac for me) I ssh into my EC2 instance first BUT... I try to enter the command line directly in my local machine without ssh to my EC2 and it works!



1) I connected to the local machine via the command line:



MacBook:~ name$


2) I entered the copy command:



scp -i /Users/name/.ssh/file.pem ubuntu@ec2-ip-address.eu-west-1.compute.amazonaws.com:/var/www/html/folder/558097BNCZ05909_heart_5.json /Users/name/Desktop/folder


I tested the second command and it works too :



scp -i /Users/name/.ssh/file.pem ubuntu@ip.address:/var/www/html/folder/558097BNCZ05909_heart_5.json /Users/name/Desktop/folder


finally the result is:



558097BNCZ05909_heart_5.json    100%    0     0.0KB/s   00:00


and it is now in my folder



Hope it will help someone :-)



@jweyrich: thanks for your help ;-)






share|improve this answer























    Your Answer






    StackExchange.ifUsing("editor", function () {
    StackExchange.using("externalEditor", function () {
    StackExchange.using("snippets", function () {
    StackExchange.snippets.init();
    });
    });
    }, "code-snippets");

    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "1"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53960186%2fcopy-file-from-ec2-to-local-computer-error-warning-identity-file-file-pem-not%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    1














    I found the answer !



    When I wanted to copy a file from an AWS EC2 instance to my local machine (mac for me) I ssh into my EC2 instance first BUT... I try to enter the command line directly in my local machine without ssh to my EC2 and it works!



    1) I connected to the local machine via the command line:



    MacBook:~ name$


    2) I entered the copy command:



    scp -i /Users/name/.ssh/file.pem ubuntu@ec2-ip-address.eu-west-1.compute.amazonaws.com:/var/www/html/folder/558097BNCZ05909_heart_5.json /Users/name/Desktop/folder


    I tested the second command and it works too :



    scp -i /Users/name/.ssh/file.pem ubuntu@ip.address:/var/www/html/folder/558097BNCZ05909_heart_5.json /Users/name/Desktop/folder


    finally the result is:



    558097BNCZ05909_heart_5.json    100%    0     0.0KB/s   00:00


    and it is now in my folder



    Hope it will help someone :-)



    @jweyrich: thanks for your help ;-)






    share|improve this answer




























      1














      I found the answer !



      When I wanted to copy a file from an AWS EC2 instance to my local machine (mac for me) I ssh into my EC2 instance first BUT... I try to enter the command line directly in my local machine without ssh to my EC2 and it works!



      1) I connected to the local machine via the command line:



      MacBook:~ name$


      2) I entered the copy command:



      scp -i /Users/name/.ssh/file.pem ubuntu@ec2-ip-address.eu-west-1.compute.amazonaws.com:/var/www/html/folder/558097BNCZ05909_heart_5.json /Users/name/Desktop/folder


      I tested the second command and it works too :



      scp -i /Users/name/.ssh/file.pem ubuntu@ip.address:/var/www/html/folder/558097BNCZ05909_heart_5.json /Users/name/Desktop/folder


      finally the result is:



      558097BNCZ05909_heart_5.json    100%    0     0.0KB/s   00:00


      and it is now in my folder



      Hope it will help someone :-)



      @jweyrich: thanks for your help ;-)






      share|improve this answer


























        1












        1








        1







        I found the answer !



        When I wanted to copy a file from an AWS EC2 instance to my local machine (mac for me) I ssh into my EC2 instance first BUT... I try to enter the command line directly in my local machine without ssh to my EC2 and it works!



        1) I connected to the local machine via the command line:



        MacBook:~ name$


        2) I entered the copy command:



        scp -i /Users/name/.ssh/file.pem ubuntu@ec2-ip-address.eu-west-1.compute.amazonaws.com:/var/www/html/folder/558097BNCZ05909_heart_5.json /Users/name/Desktop/folder


        I tested the second command and it works too :



        scp -i /Users/name/.ssh/file.pem ubuntu@ip.address:/var/www/html/folder/558097BNCZ05909_heart_5.json /Users/name/Desktop/folder


        finally the result is:



        558097BNCZ05909_heart_5.json    100%    0     0.0KB/s   00:00


        and it is now in my folder



        Hope it will help someone :-)



        @jweyrich: thanks for your help ;-)






        share|improve this answer













        I found the answer !



        When I wanted to copy a file from an AWS EC2 instance to my local machine (mac for me) I ssh into my EC2 instance first BUT... I try to enter the command line directly in my local machine without ssh to my EC2 and it works!



        1) I connected to the local machine via the command line:



        MacBook:~ name$


        2) I entered the copy command:



        scp -i /Users/name/.ssh/file.pem ubuntu@ec2-ip-address.eu-west-1.compute.amazonaws.com:/var/www/html/folder/558097BNCZ05909_heart_5.json /Users/name/Desktop/folder


        I tested the second command and it works too :



        scp -i /Users/name/.ssh/file.pem ubuntu@ip.address:/var/www/html/folder/558097BNCZ05909_heart_5.json /Users/name/Desktop/folder


        finally the result is:



        558097BNCZ05909_heart_5.json    100%    0     0.0KB/s   00:00


        and it is now in my folder



        Hope it will help someone :-)



        @jweyrich: thanks for your help ;-)







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Dec 28 '18 at 15:58









        IdrissIdriss

        142




        142






























            draft saved

            draft discarded




















































            Thanks for contributing an answer to Stack Overflow!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53960186%2fcopy-file-from-ec2-to-local-computer-error-warning-identity-file-file-pem-not%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            Monofisismo

            Angular Downloading a file using contenturl with Basic Authentication

            Olmecas