Change owner over ssh with sudo user











up vote
0
down vote

favorite












I need to copy a file from local to remote server. I am using rsync for this with passwordless connection. I am not able to change permissions for the file after migration.



I am using this command.



rsync -ab --suffix _BKP"$(date +%Y%d%m)" --perms --chmod=ug+rwx,o+rx --chown=sai:sai /home/yesh/yesh_final_V1.sh yesh@myserver.com:/data001/yesh


yesh is also a super user. My rsync version is rsync-3.1.1-1.el7.rfx.x86_64.



Am I doing anything wrong? If so please correct me. Or is there any other way to change permissions on remote server using sudo user?



Note: I don't want to login into server and change. I need this to be done from my local itself, kind of running from a script.










share|improve this question




























    up vote
    0
    down vote

    favorite












    I need to copy a file from local to remote server. I am using rsync for this with passwordless connection. I am not able to change permissions for the file after migration.



    I am using this command.



    rsync -ab --suffix _BKP"$(date +%Y%d%m)" --perms --chmod=ug+rwx,o+rx --chown=sai:sai /home/yesh/yesh_final_V1.sh yesh@myserver.com:/data001/yesh


    yesh is also a super user. My rsync version is rsync-3.1.1-1.el7.rfx.x86_64.



    Am I doing anything wrong? If so please correct me. Or is there any other way to change permissions on remote server using sudo user?



    Note: I don't want to login into server and change. I need this to be done from my local itself, kind of running from a script.










    share|improve this question


























      up vote
      0
      down vote

      favorite









      up vote
      0
      down vote

      favorite











      I need to copy a file from local to remote server. I am using rsync for this with passwordless connection. I am not able to change permissions for the file after migration.



      I am using this command.



      rsync -ab --suffix _BKP"$(date +%Y%d%m)" --perms --chmod=ug+rwx,o+rx --chown=sai:sai /home/yesh/yesh_final_V1.sh yesh@myserver.com:/data001/yesh


      yesh is also a super user. My rsync version is rsync-3.1.1-1.el7.rfx.x86_64.



      Am I doing anything wrong? If so please correct me. Or is there any other way to change permissions on remote server using sudo user?



      Note: I don't want to login into server and change. I need this to be done from my local itself, kind of running from a script.










      share|improve this question















      I need to copy a file from local to remote server. I am using rsync for this with passwordless connection. I am not able to change permissions for the file after migration.



      I am using this command.



      rsync -ab --suffix _BKP"$(date +%Y%d%m)" --perms --chmod=ug+rwx,o+rx --chown=sai:sai /home/yesh/yesh_final_V1.sh yesh@myserver.com:/data001/yesh


      yesh is also a super user. My rsync version is rsync-3.1.1-1.el7.rfx.x86_64.



      Am I doing anything wrong? If so please correct me. Or is there any other way to change permissions on remote server using sudo user?



      Note: I don't want to login into server and change. I need this to be done from my local itself, kind of running from a script.







      server permissions scripts ssh rsync






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Nov 12 at 23:06









      karel

      54.6k11118137




      54.6k11118137










      asked Nov 12 at 19:00









      yeswanth

      286




      286






















          1 Answer
          1






          active

          oldest

          votes

















          up vote
          0
          down vote













          Normally, it would be sufficient to just use ssh directly, for one-off implementation.



          One-Off Operation



          as long as yesh is super-user and you know the password for yesh, you can do the following to update over ssh.



          ssh as yesh (assumes you have the password).



          ssh yesh@myserver.com



          Change to make script executable



          Ubuntu> sudo chmod 755 /home/yesh/yesh_final_V1.sh



          Scripted Operation



          The author of the question commented that they wish to do this in scripted form. To achieve this, you can use the "sshpass" functionality, which has to be present on the host computer.



          sudo apt-get install sshpass



          To use it, you may find the below bash script example useful:



          function scripted_remote_operation {
          sshpass -f password.txt ssh -o StrictHostKeyChecking=no -t -t yesh@myserver.com -o StrictHostKeyChecking=no <<EOF
          sudo chmod 755 /home/yesh/yesh_final_V1.sh
          exit
          EOF
          }



          This can be executed from the host computer as part of a script, automatically logging in, making the change as requested. Unfortunately, this will require that the password requirement for users with admin privileges, be disabled (NOT RECOMMENDED).



          For example, in the directory



          /etc/sudoers.d



          You could include the file



          010_ubuntu-nopasswd



          with the contents



          root ALL=(ALL) NOPASSWD: ALL



          This information is provided for clarity only. It is absolutely not a good idea to disable the sudo password on a machine.



          Possible Answer Without sudo on the remote machine



          If the file is installed remotely with yesh as the owner, then the chmod operation can happen without elevated privileges, and the chown operation can be included in the same sshpass script.






          share|improve this answer










          New contributor




          Keitai Otaku is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
          Check out our Code of Conduct.


















          • tq for your time. I should do this with out logging into the server kind of running from script.
            – yeswanth
            Nov 12 at 19:43













          Your Answer








          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "89"
          };
          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: 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%2faskubuntu.com%2fquestions%2f1092309%2fchange-owner-over-ssh-with-sudo-user%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








          up vote
          0
          down vote













          Normally, it would be sufficient to just use ssh directly, for one-off implementation.



          One-Off Operation



          as long as yesh is super-user and you know the password for yesh, you can do the following to update over ssh.



          ssh as yesh (assumes you have the password).



          ssh yesh@myserver.com



          Change to make script executable



          Ubuntu> sudo chmod 755 /home/yesh/yesh_final_V1.sh



          Scripted Operation



          The author of the question commented that they wish to do this in scripted form. To achieve this, you can use the "sshpass" functionality, which has to be present on the host computer.



          sudo apt-get install sshpass



          To use it, you may find the below bash script example useful:



          function scripted_remote_operation {
          sshpass -f password.txt ssh -o StrictHostKeyChecking=no -t -t yesh@myserver.com -o StrictHostKeyChecking=no <<EOF
          sudo chmod 755 /home/yesh/yesh_final_V1.sh
          exit
          EOF
          }



          This can be executed from the host computer as part of a script, automatically logging in, making the change as requested. Unfortunately, this will require that the password requirement for users with admin privileges, be disabled (NOT RECOMMENDED).



          For example, in the directory



          /etc/sudoers.d



          You could include the file



          010_ubuntu-nopasswd



          with the contents



          root ALL=(ALL) NOPASSWD: ALL



          This information is provided for clarity only. It is absolutely not a good idea to disable the sudo password on a machine.



          Possible Answer Without sudo on the remote machine



          If the file is installed remotely with yesh as the owner, then the chmod operation can happen without elevated privileges, and the chown operation can be included in the same sshpass script.






          share|improve this answer










          New contributor




          Keitai Otaku is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
          Check out our Code of Conduct.


















          • tq for your time. I should do this with out logging into the server kind of running from script.
            – yeswanth
            Nov 12 at 19:43

















          up vote
          0
          down vote













          Normally, it would be sufficient to just use ssh directly, for one-off implementation.



          One-Off Operation



          as long as yesh is super-user and you know the password for yesh, you can do the following to update over ssh.



          ssh as yesh (assumes you have the password).



          ssh yesh@myserver.com



          Change to make script executable



          Ubuntu> sudo chmod 755 /home/yesh/yesh_final_V1.sh



          Scripted Operation



          The author of the question commented that they wish to do this in scripted form. To achieve this, you can use the "sshpass" functionality, which has to be present on the host computer.



          sudo apt-get install sshpass



          To use it, you may find the below bash script example useful:



          function scripted_remote_operation {
          sshpass -f password.txt ssh -o StrictHostKeyChecking=no -t -t yesh@myserver.com -o StrictHostKeyChecking=no <<EOF
          sudo chmod 755 /home/yesh/yesh_final_V1.sh
          exit
          EOF
          }



          This can be executed from the host computer as part of a script, automatically logging in, making the change as requested. Unfortunately, this will require that the password requirement for users with admin privileges, be disabled (NOT RECOMMENDED).



          For example, in the directory



          /etc/sudoers.d



          You could include the file



          010_ubuntu-nopasswd



          with the contents



          root ALL=(ALL) NOPASSWD: ALL



          This information is provided for clarity only. It is absolutely not a good idea to disable the sudo password on a machine.



          Possible Answer Without sudo on the remote machine



          If the file is installed remotely with yesh as the owner, then the chmod operation can happen without elevated privileges, and the chown operation can be included in the same sshpass script.






          share|improve this answer










          New contributor




          Keitai Otaku is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
          Check out our Code of Conduct.


















          • tq for your time. I should do this with out logging into the server kind of running from script.
            – yeswanth
            Nov 12 at 19:43















          up vote
          0
          down vote










          up vote
          0
          down vote









          Normally, it would be sufficient to just use ssh directly, for one-off implementation.



          One-Off Operation



          as long as yesh is super-user and you know the password for yesh, you can do the following to update over ssh.



          ssh as yesh (assumes you have the password).



          ssh yesh@myserver.com



          Change to make script executable



          Ubuntu> sudo chmod 755 /home/yesh/yesh_final_V1.sh



          Scripted Operation



          The author of the question commented that they wish to do this in scripted form. To achieve this, you can use the "sshpass" functionality, which has to be present on the host computer.



          sudo apt-get install sshpass



          To use it, you may find the below bash script example useful:



          function scripted_remote_operation {
          sshpass -f password.txt ssh -o StrictHostKeyChecking=no -t -t yesh@myserver.com -o StrictHostKeyChecking=no <<EOF
          sudo chmod 755 /home/yesh/yesh_final_V1.sh
          exit
          EOF
          }



          This can be executed from the host computer as part of a script, automatically logging in, making the change as requested. Unfortunately, this will require that the password requirement for users with admin privileges, be disabled (NOT RECOMMENDED).



          For example, in the directory



          /etc/sudoers.d



          You could include the file



          010_ubuntu-nopasswd



          with the contents



          root ALL=(ALL) NOPASSWD: ALL



          This information is provided for clarity only. It is absolutely not a good idea to disable the sudo password on a machine.



          Possible Answer Without sudo on the remote machine



          If the file is installed remotely with yesh as the owner, then the chmod operation can happen without elevated privileges, and the chown operation can be included in the same sshpass script.






          share|improve this answer










          New contributor




          Keitai Otaku is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
          Check out our Code of Conduct.









          Normally, it would be sufficient to just use ssh directly, for one-off implementation.



          One-Off Operation



          as long as yesh is super-user and you know the password for yesh, you can do the following to update over ssh.



          ssh as yesh (assumes you have the password).



          ssh yesh@myserver.com



          Change to make script executable



          Ubuntu> sudo chmod 755 /home/yesh/yesh_final_V1.sh



          Scripted Operation



          The author of the question commented that they wish to do this in scripted form. To achieve this, you can use the "sshpass" functionality, which has to be present on the host computer.



          sudo apt-get install sshpass



          To use it, you may find the below bash script example useful:



          function scripted_remote_operation {
          sshpass -f password.txt ssh -o StrictHostKeyChecking=no -t -t yesh@myserver.com -o StrictHostKeyChecking=no <<EOF
          sudo chmod 755 /home/yesh/yesh_final_V1.sh
          exit
          EOF
          }



          This can be executed from the host computer as part of a script, automatically logging in, making the change as requested. Unfortunately, this will require that the password requirement for users with admin privileges, be disabled (NOT RECOMMENDED).



          For example, in the directory



          /etc/sudoers.d



          You could include the file



          010_ubuntu-nopasswd



          with the contents



          root ALL=(ALL) NOPASSWD: ALL



          This information is provided for clarity only. It is absolutely not a good idea to disable the sudo password on a machine.



          Possible Answer Without sudo on the remote machine



          If the file is installed remotely with yesh as the owner, then the chmod operation can happen without elevated privileges, and the chown operation can be included in the same sshpass script.







          share|improve this answer










          New contributor




          Keitai Otaku is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
          Check out our Code of Conduct.









          share|improve this answer



          share|improve this answer








          edited Nov 12 at 20:16





















          New contributor




          Keitai Otaku is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
          Check out our Code of Conduct.









          answered Nov 12 at 19:19









          Keitai Otaku

          463




          463




          New contributor




          Keitai Otaku is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
          Check out our Code of Conduct.





          New contributor





          Keitai Otaku is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
          Check out our Code of Conduct.






          Keitai Otaku is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
          Check out our Code of Conduct.












          • tq for your time. I should do this with out logging into the server kind of running from script.
            – yeswanth
            Nov 12 at 19:43




















          • tq for your time. I should do this with out logging into the server kind of running from script.
            – yeswanth
            Nov 12 at 19:43


















          tq for your time. I should do this with out logging into the server kind of running from script.
          – yeswanth
          Nov 12 at 19:43






          tq for your time. I should do this with out logging into the server kind of running from script.
          – yeswanth
          Nov 12 at 19:43




















           

          draft saved


          draft discarded



















































           


          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f1092309%2fchange-owner-over-ssh-with-sudo-user%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

          mysqli_query(): Empty query in /home/lucindabrummitt/public_html/blog/wp-includes/wp-db.php on line 1924

          How to change which sound is reproduced for terminal bell?

          Can I use Tabulator js library in my java Spring + Thymeleaf project?