Trying to execute a script (that creates folders) on remote server: “Permission denied”

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












0















I wrote a very simple script that should allow me to create directories with specific permissions on a remote server.



I used the command to execute the script to the remote server:



stan@192.168.159.133 /root/Documents/script


And I got this answer:



bash: /root/Documents/script: Permission denied
Connection to 192.168.159.133 closed.


I'm working on Fedora 20, and the server is on Ubuntu 18.04.1.



I tried to modify the permission on my script document with chmod:



chmod 777 script


At first I tried to execute the script with the SSL connection integrated inside of the script (you can see it in my script).



#!/bin/bash

#Connecting to Ubuntu Server
#ssh stan@192.168.159.133

#specifying the directory where I want to create my two directories
cd /home/stan

#Creating the first directory "PublicFolder" and assigning permissions
mkdir PublicFolder
chmod -R 606 PublicFolder

#Creating the first directory "PrivateFolder" and assigning permissions
PrivateFolder
chmod -R 604 PrivateFolder









share|improve this question
























  • Possibly unrelated: There seems to be a mkdir missing on the penultimate line of that script.

    – Kusalananda
    Feb 18 at 19:47











  • Kusalananda, you're right. It's in my script though, I guess I deleted that line by mistake while I was editing my post. I'm sorry about that. Thank you!

    – Pak
    Feb 18 at 19:52











  • Does the user stan have access to the script at all on the server? The /root directory is usually (and should be) inaccessible by non-root users.

    – Kusalananda
    Feb 18 at 20:00











  • I would expect bash: stan@192.168.159.133: command not found.

    – ctrl-alt-delor
    Feb 18 at 20:11







  • 1





    I found the answer: I executed this command on my local machine: ssh stan@192.168.159.133 'bash -s' < script . I don't really know why it works yet, but I'll work on that! Thank you very much for all of your answers.

    – Pak
    Feb 19 at 0:35
















0















I wrote a very simple script that should allow me to create directories with specific permissions on a remote server.



I used the command to execute the script to the remote server:



stan@192.168.159.133 /root/Documents/script


And I got this answer:



bash: /root/Documents/script: Permission denied
Connection to 192.168.159.133 closed.


I'm working on Fedora 20, and the server is on Ubuntu 18.04.1.



I tried to modify the permission on my script document with chmod:



chmod 777 script


At first I tried to execute the script with the SSL connection integrated inside of the script (you can see it in my script).



#!/bin/bash

#Connecting to Ubuntu Server
#ssh stan@192.168.159.133

#specifying the directory where I want to create my two directories
cd /home/stan

#Creating the first directory "PublicFolder" and assigning permissions
mkdir PublicFolder
chmod -R 606 PublicFolder

#Creating the first directory "PrivateFolder" and assigning permissions
PrivateFolder
chmod -R 604 PrivateFolder









share|improve this question
























  • Possibly unrelated: There seems to be a mkdir missing on the penultimate line of that script.

    – Kusalananda
    Feb 18 at 19:47











  • Kusalananda, you're right. It's in my script though, I guess I deleted that line by mistake while I was editing my post. I'm sorry about that. Thank you!

    – Pak
    Feb 18 at 19:52











  • Does the user stan have access to the script at all on the server? The /root directory is usually (and should be) inaccessible by non-root users.

    – Kusalananda
    Feb 18 at 20:00











  • I would expect bash: stan@192.168.159.133: command not found.

    – ctrl-alt-delor
    Feb 18 at 20:11







  • 1





    I found the answer: I executed this command on my local machine: ssh stan@192.168.159.133 'bash -s' < script . I don't really know why it works yet, but I'll work on that! Thank you very much for all of your answers.

    – Pak
    Feb 19 at 0:35














0












0








0








I wrote a very simple script that should allow me to create directories with specific permissions on a remote server.



I used the command to execute the script to the remote server:



stan@192.168.159.133 /root/Documents/script


And I got this answer:



bash: /root/Documents/script: Permission denied
Connection to 192.168.159.133 closed.


I'm working on Fedora 20, and the server is on Ubuntu 18.04.1.



I tried to modify the permission on my script document with chmod:



chmod 777 script


At first I tried to execute the script with the SSL connection integrated inside of the script (you can see it in my script).



#!/bin/bash

#Connecting to Ubuntu Server
#ssh stan@192.168.159.133

#specifying the directory where I want to create my two directories
cd /home/stan

#Creating the first directory "PublicFolder" and assigning permissions
mkdir PublicFolder
chmod -R 606 PublicFolder

#Creating the first directory "PrivateFolder" and assigning permissions
PrivateFolder
chmod -R 604 PrivateFolder









share|improve this question
















I wrote a very simple script that should allow me to create directories with specific permissions on a remote server.



I used the command to execute the script to the remote server:



stan@192.168.159.133 /root/Documents/script


And I got this answer:



bash: /root/Documents/script: Permission denied
Connection to 192.168.159.133 closed.


I'm working on Fedora 20, and the server is on Ubuntu 18.04.1.



I tried to modify the permission on my script document with chmod:



chmod 777 script


At first I tried to execute the script with the SSL connection integrated inside of the script (you can see it in my script).



#!/bin/bash

#Connecting to Ubuntu Server
#ssh stan@192.168.159.133

#specifying the directory where I want to create my two directories
cd /home/stan

#Creating the first directory "PublicFolder" and assigning permissions
mkdir PublicFolder
chmod -R 606 PublicFolder

#Creating the first directory "PrivateFolder" and assigning permissions
PrivateFolder
chmod -R 604 PrivateFolder






shell-script ubuntu fedora permissions remote






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Feb 18 at 19:44









Rui F Ribeiro

41.5k1482140




41.5k1482140










asked Feb 18 at 19:27









PakPak

1




1












  • Possibly unrelated: There seems to be a mkdir missing on the penultimate line of that script.

    – Kusalananda
    Feb 18 at 19:47











  • Kusalananda, you're right. It's in my script though, I guess I deleted that line by mistake while I was editing my post. I'm sorry about that. Thank you!

    – Pak
    Feb 18 at 19:52











  • Does the user stan have access to the script at all on the server? The /root directory is usually (and should be) inaccessible by non-root users.

    – Kusalananda
    Feb 18 at 20:00











  • I would expect bash: stan@192.168.159.133: command not found.

    – ctrl-alt-delor
    Feb 18 at 20:11







  • 1





    I found the answer: I executed this command on my local machine: ssh stan@192.168.159.133 'bash -s' < script . I don't really know why it works yet, but I'll work on that! Thank you very much for all of your answers.

    – Pak
    Feb 19 at 0:35


















  • Possibly unrelated: There seems to be a mkdir missing on the penultimate line of that script.

    – Kusalananda
    Feb 18 at 19:47











  • Kusalananda, you're right. It's in my script though, I guess I deleted that line by mistake while I was editing my post. I'm sorry about that. Thank you!

    – Pak
    Feb 18 at 19:52











  • Does the user stan have access to the script at all on the server? The /root directory is usually (and should be) inaccessible by non-root users.

    – Kusalananda
    Feb 18 at 20:00











  • I would expect bash: stan@192.168.159.133: command not found.

    – ctrl-alt-delor
    Feb 18 at 20:11







  • 1





    I found the answer: I executed this command on my local machine: ssh stan@192.168.159.133 'bash -s' < script . I don't really know why it works yet, but I'll work on that! Thank you very much for all of your answers.

    – Pak
    Feb 19 at 0:35

















Possibly unrelated: There seems to be a mkdir missing on the penultimate line of that script.

– Kusalananda
Feb 18 at 19:47





Possibly unrelated: There seems to be a mkdir missing on the penultimate line of that script.

– Kusalananda
Feb 18 at 19:47













Kusalananda, you're right. It's in my script though, I guess I deleted that line by mistake while I was editing my post. I'm sorry about that. Thank you!

– Pak
Feb 18 at 19:52





Kusalananda, you're right. It's in my script though, I guess I deleted that line by mistake while I was editing my post. I'm sorry about that. Thank you!

– Pak
Feb 18 at 19:52













Does the user stan have access to the script at all on the server? The /root directory is usually (and should be) inaccessible by non-root users.

– Kusalananda
Feb 18 at 20:00





Does the user stan have access to the script at all on the server? The /root directory is usually (and should be) inaccessible by non-root users.

– Kusalananda
Feb 18 at 20:00













I would expect bash: stan@192.168.159.133: command not found.

– ctrl-alt-delor
Feb 18 at 20:11






I would expect bash: stan@192.168.159.133: command not found.

– ctrl-alt-delor
Feb 18 at 20:11





1




1





I found the answer: I executed this command on my local machine: ssh stan@192.168.159.133 'bash -s' < script . I don't really know why it works yet, but I'll work on that! Thank you very much for all of your answers.

– Pak
Feb 19 at 0:35






I found the answer: I executed this command on my local machine: ssh stan@192.168.159.133 'bash -s' < script . I don't really know why it works yet, but I'll work on that! Thank you very much for all of your answers.

– Pak
Feb 19 at 0:35











1 Answer
1






active

oldest

votes


















0














I see a few possibilities that could be causing your issue.
1. There is no ssh in front of your command. Try this:
ssh stan@192.168.159.133 /root/Documents/script

2. you are logging in to the remote server as stan and trying to execute a script that is under the user root. Stan will not have access to this script, even if you change the permissions on the file script.

3. Permissions flow down the directory tree with the x attribute. By default, /root will not allow access to anything below it.
ssh stan@192.168.159.133 ls -ld /root
ssh stan@192.168.159.133 ls -ld /root/Documents

You will probably see something like this:
drwxr----- root root /root

Or, more likely, you will get a permission denied error, because stan can't see in to /root.

Possibilities:
BAD root:192.168.159.133 # chmod -R a+rx /root
Better move /root/Documents/script /tmp & set execute permissions on /tmp
BEST cread a directory called /share, move /root/Documents/script to /share and set r+x permissions on /share






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',
    autoActivateHeartbeat: false,
    convertImagesToLinks: false,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: null,
    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%2funix.stackexchange.com%2fquestions%2f501435%2ftrying-to-execute-a-script-that-creates-folders-on-remote-server-permission%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









    0














    I see a few possibilities that could be causing your issue.
    1. There is no ssh in front of your command. Try this:
    ssh stan@192.168.159.133 /root/Documents/script

    2. you are logging in to the remote server as stan and trying to execute a script that is under the user root. Stan will not have access to this script, even if you change the permissions on the file script.

    3. Permissions flow down the directory tree with the x attribute. By default, /root will not allow access to anything below it.
    ssh stan@192.168.159.133 ls -ld /root
    ssh stan@192.168.159.133 ls -ld /root/Documents

    You will probably see something like this:
    drwxr----- root root /root

    Or, more likely, you will get a permission denied error, because stan can't see in to /root.

    Possibilities:
    BAD root:192.168.159.133 # chmod -R a+rx /root
    Better move /root/Documents/script /tmp & set execute permissions on /tmp
    BEST cread a directory called /share, move /root/Documents/script to /share and set r+x permissions on /share






    share|improve this answer





























      0














      I see a few possibilities that could be causing your issue.
      1. There is no ssh in front of your command. Try this:
      ssh stan@192.168.159.133 /root/Documents/script

      2. you are logging in to the remote server as stan and trying to execute a script that is under the user root. Stan will not have access to this script, even if you change the permissions on the file script.

      3. Permissions flow down the directory tree with the x attribute. By default, /root will not allow access to anything below it.
      ssh stan@192.168.159.133 ls -ld /root
      ssh stan@192.168.159.133 ls -ld /root/Documents

      You will probably see something like this:
      drwxr----- root root /root

      Or, more likely, you will get a permission denied error, because stan can't see in to /root.

      Possibilities:
      BAD root:192.168.159.133 # chmod -R a+rx /root
      Better move /root/Documents/script /tmp & set execute permissions on /tmp
      BEST cread a directory called /share, move /root/Documents/script to /share and set r+x permissions on /share






      share|improve this answer



























        0












        0








        0







        I see a few possibilities that could be causing your issue.
        1. There is no ssh in front of your command. Try this:
        ssh stan@192.168.159.133 /root/Documents/script

        2. you are logging in to the remote server as stan and trying to execute a script that is under the user root. Stan will not have access to this script, even if you change the permissions on the file script.

        3. Permissions flow down the directory tree with the x attribute. By default, /root will not allow access to anything below it.
        ssh stan@192.168.159.133 ls -ld /root
        ssh stan@192.168.159.133 ls -ld /root/Documents

        You will probably see something like this:
        drwxr----- root root /root

        Or, more likely, you will get a permission denied error, because stan can't see in to /root.

        Possibilities:
        BAD root:192.168.159.133 # chmod -R a+rx /root
        Better move /root/Documents/script /tmp & set execute permissions on /tmp
        BEST cread a directory called /share, move /root/Documents/script to /share and set r+x permissions on /share






        share|improve this answer















        I see a few possibilities that could be causing your issue.
        1. There is no ssh in front of your command. Try this:
        ssh stan@192.168.159.133 /root/Documents/script

        2. you are logging in to the remote server as stan and trying to execute a script that is under the user root. Stan will not have access to this script, even if you change the permissions on the file script.

        3. Permissions flow down the directory tree with the x attribute. By default, /root will not allow access to anything below it.
        ssh stan@192.168.159.133 ls -ld /root
        ssh stan@192.168.159.133 ls -ld /root/Documents

        You will probably see something like this:
        drwxr----- root root /root

        Or, more likely, you will get a permission denied error, because stan can't see in to /root.

        Possibilities:
        BAD root:192.168.159.133 # chmod -R a+rx /root
        Better move /root/Documents/script /tmp & set execute permissions on /tmp
        BEST cread a directory called /share, move /root/Documents/script to /share and set r+x permissions on /share







        share|improve this answer














        share|improve this answer



        share|improve this answer








        edited Feb 19 at 0:41

























        answered Feb 19 at 0:35









        Scottie HScottie H

        676




        676



























            draft saved

            draft discarded
















































            Thanks for contributing an answer to Unix & Linux Stack Exchange!


            • 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%2funix.stackexchange.com%2fquestions%2f501435%2ftrying-to-execute-a-script-that-creates-folders-on-remote-server-permission%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

            How to check contact read email or not when send email to Individual?

            Displaying single band from multi-band raster using QGIS

            How many registers does an x86_64 CPU actually have?