scp file from machine A to machine with no password prompt and copy same file to different location

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
0
down vote

favorite












I am trying to write a shell script through which i want to copy file from machineA to machine B.I have already setup passwordless connection .In the machine B again the samefile i want to copy to different path in the which
the directory is owned by different user. How can I achive this



Example:




  1. Machine A



    scp /home/user/txt user@xhost/home/user/txt



  2. Machine B



    It simply copies the file without asking password under home directory



    machineB:/home/user/


    I again want to copy the same file into diffrent location i get permission denied:



    cp /home/user/txt /apps/java/software/ # (permission denied)










share|improve this question



















  • 1




    You've got two requirements: (a) scp the file to a target, (b) execute a command as a different user on that target. Both parts are answered (separately) here on Unix & Linux.
    – roaima
    Sep 21 at 23:17














up vote
0
down vote

favorite












I am trying to write a shell script through which i want to copy file from machineA to machine B.I have already setup passwordless connection .In the machine B again the samefile i want to copy to different path in the which
the directory is owned by different user. How can I achive this



Example:




  1. Machine A



    scp /home/user/txt user@xhost/home/user/txt



  2. Machine B



    It simply copies the file without asking password under home directory



    machineB:/home/user/


    I again want to copy the same file into diffrent location i get permission denied:



    cp /home/user/txt /apps/java/software/ # (permission denied)










share|improve this question



















  • 1




    You've got two requirements: (a) scp the file to a target, (b) execute a command as a different user on that target. Both parts are answered (separately) here on Unix & Linux.
    – roaima
    Sep 21 at 23:17












up vote
0
down vote

favorite









up vote
0
down vote

favorite











I am trying to write a shell script through which i want to copy file from machineA to machine B.I have already setup passwordless connection .In the machine B again the samefile i want to copy to different path in the which
the directory is owned by different user. How can I achive this



Example:




  1. Machine A



    scp /home/user/txt user@xhost/home/user/txt



  2. Machine B



    It simply copies the file without asking password under home directory



    machineB:/home/user/


    I again want to copy the same file into diffrent location i get permission denied:



    cp /home/user/txt /apps/java/software/ # (permission denied)










share|improve this question















I am trying to write a shell script through which i want to copy file from machineA to machine B.I have already setup passwordless connection .In the machine B again the samefile i want to copy to different path in the which
the directory is owned by different user. How can I achive this



Example:




  1. Machine A



    scp /home/user/txt user@xhost/home/user/txt



  2. Machine B



    It simply copies the file without asking password under home directory



    machineB:/home/user/


    I again want to copy the same file into diffrent location i get permission denied:



    cp /home/user/txt /apps/java/software/ # (permission denied)







linux scp






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Sep 21 at 23:16









roaima

40.8k547110




40.8k547110










asked Sep 21 at 23:02









Ramya aws

1




1







  • 1




    You've got two requirements: (a) scp the file to a target, (b) execute a command as a different user on that target. Both parts are answered (separately) here on Unix & Linux.
    – roaima
    Sep 21 at 23:17












  • 1




    You've got two requirements: (a) scp the file to a target, (b) execute a command as a different user on that target. Both parts are answered (separately) here on Unix & Linux.
    – roaima
    Sep 21 at 23:17







1




1




You've got two requirements: (a) scp the file to a target, (b) execute a command as a different user on that target. Both parts are answered (separately) here on Unix & Linux.
– roaima
Sep 21 at 23:17




You've got two requirements: (a) scp the file to a target, (b) execute a command as a different user on that target. Both parts are answered (separately) here on Unix & Linux.
– roaima
Sep 21 at 23:17










1 Answer
1






active

oldest

votes

















up vote
0
down vote













When you copy "the same file" to a different location, you need to scp with a user account which has access to the file AND the location you're copying it to. Without such permissions you'll get permission denied.






share|improve this answer




















    Your Answer







    StackExchange.ready(function()
    var channelOptions =
    tags: "".split(" "),
    id: "106"
    ;
    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',
    convertImagesToLinks: false,
    noModals: false,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: null,
    bindNavPrevention: true,
    postfix: "",
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    );



    );













     

    draft saved


    draft discarded


















    StackExchange.ready(
    function ()
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f470644%2fscp-file-from-machine-a-to-machine-with-no-password-prompt-and-copy-same-file-to%23new-answer', 'question_page');

    );

    Post as a guest






























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes








    up vote
    0
    down vote













    When you copy "the same file" to a different location, you need to scp with a user account which has access to the file AND the location you're copying it to. Without such permissions you'll get permission denied.






    share|improve this answer
























      up vote
      0
      down vote













      When you copy "the same file" to a different location, you need to scp with a user account which has access to the file AND the location you're copying it to. Without such permissions you'll get permission denied.






      share|improve this answer






















        up vote
        0
        down vote










        up vote
        0
        down vote









        When you copy "the same file" to a different location, you need to scp with a user account which has access to the file AND the location you're copying it to. Without such permissions you'll get permission denied.






        share|improve this answer












        When you copy "the same file" to a different location, you need to scp with a user account which has access to the file AND the location you're copying it to. Without such permissions you'll get permission denied.







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Sep 22 at 1:16









        Emmanuel Rosa

        2,5851411




        2,5851411



























             

            draft saved


            draft discarded















































             


            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f470644%2fscp-file-from-machine-a-to-machine-with-no-password-prompt-and-copy-same-file-to%23new-answer', 'question_page');

            );

            Post as a guest













































































            Popular posts from this blog

            Peggy Mitchell

            Palaiologos

            The Forum (Inglewood, California)