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.
server permissions scripts ssh rsync
add a comment |
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.
server permissions scripts ssh rsync
add a comment |
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.
server permissions scripts ssh rsync
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
server permissions scripts ssh rsync
edited Nov 12 at 23:06
karel
54.6k11118137
54.6k11118137
asked Nov 12 at 19:00
yeswanth
286
286
add a comment |
add a comment |
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.
New contributor
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
add a comment |
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.
New contributor
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
add a comment |
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.
New contributor
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
add a comment |
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.
New contributor
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.
New contributor
edited Nov 12 at 20:16
New contributor
answered Nov 12 at 19:19
Keitai Otaku
463
463
New contributor
New contributor
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
add a comment |
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
add a comment |
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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