Need to prefer file ownership while uploading through scp
Clash Royale CLAN TAG#URR8PPP
I have been tring to upload a file through a normal user to the Amazon Gnu/Linux server, but file owner is not preferring after a successful upload.
File ownership is taken from the directory, not from the user which I have used to move the file.
Example:
scp -i xxx.pem filename surya@publicipaddress:/home/surya
ls -lh filename
-rwxrwxr-x 1 ec2-user ec2-user 1.7K Dec 24 11:30 filename
Here, After uploading a file, the ownership should be surya
as I have used surya
user to upload the file.
scp
add a comment |
I have been tring to upload a file through a normal user to the Amazon Gnu/Linux server, but file owner is not preferring after a successful upload.
File ownership is taken from the directory, not from the user which I have used to move the file.
Example:
scp -i xxx.pem filename surya@publicipaddress:/home/surya
ls -lh filename
-rwxrwxr-x 1 ec2-user ec2-user 1.7K Dec 24 11:30 filename
Here, After uploading a file, the ownership should be surya
as I have used surya
user to upload the file.
scp
What meaning are you attaching to “Preferring”? Are those two commands on the same machine?
– ctrl-alt-delor
Dec 24 '18 at 10:46
Is your "ls" output from running ls on the remote system, or the local system? Did "filename" already exist on the remote system before you ran scp?
– Kenster
Dec 24 '18 at 15:14
There may be something in thesshd_config
that is forcing ownership change, or perhaps asetuid
andsetgid
bit is set on a directory above the one you are uploading to (this will also force ownership change).
– ivanivan
Dec 24 '18 at 15:30
What is the output ofssh -i xxx.pem sutya@publicipaddress ls -lnd . filename
? Unix stores the ownership of a file as a numeric value, andls
consults things like the password file to translate them to names. Ifec2-user
andsurya
have the same number then as far as file ownership is concerned they are the same user (they can have different passwords etc)
– icarus
Dec 25 '18 at 17:31
add a comment |
I have been tring to upload a file through a normal user to the Amazon Gnu/Linux server, but file owner is not preferring after a successful upload.
File ownership is taken from the directory, not from the user which I have used to move the file.
Example:
scp -i xxx.pem filename surya@publicipaddress:/home/surya
ls -lh filename
-rwxrwxr-x 1 ec2-user ec2-user 1.7K Dec 24 11:30 filename
Here, After uploading a file, the ownership should be surya
as I have used surya
user to upload the file.
scp
I have been tring to upload a file through a normal user to the Amazon Gnu/Linux server, but file owner is not preferring after a successful upload.
File ownership is taken from the directory, not from the user which I have used to move the file.
Example:
scp -i xxx.pem filename surya@publicipaddress:/home/surya
ls -lh filename
-rwxrwxr-x 1 ec2-user ec2-user 1.7K Dec 24 11:30 filename
Here, After uploading a file, the ownership should be surya
as I have used surya
user to upload the file.
scp
scp
edited Dec 24 '18 at 10:44
ctrl-alt-delor
10.9k41957
10.9k41957
asked Dec 24 '18 at 6:08
Surya SG
61
61
What meaning are you attaching to “Preferring”? Are those two commands on the same machine?
– ctrl-alt-delor
Dec 24 '18 at 10:46
Is your "ls" output from running ls on the remote system, or the local system? Did "filename" already exist on the remote system before you ran scp?
– Kenster
Dec 24 '18 at 15:14
There may be something in thesshd_config
that is forcing ownership change, or perhaps asetuid
andsetgid
bit is set on a directory above the one you are uploading to (this will also force ownership change).
– ivanivan
Dec 24 '18 at 15:30
What is the output ofssh -i xxx.pem sutya@publicipaddress ls -lnd . filename
? Unix stores the ownership of a file as a numeric value, andls
consults things like the password file to translate them to names. Ifec2-user
andsurya
have the same number then as far as file ownership is concerned they are the same user (they can have different passwords etc)
– icarus
Dec 25 '18 at 17:31
add a comment |
What meaning are you attaching to “Preferring”? Are those two commands on the same machine?
– ctrl-alt-delor
Dec 24 '18 at 10:46
Is your "ls" output from running ls on the remote system, or the local system? Did "filename" already exist on the remote system before you ran scp?
– Kenster
Dec 24 '18 at 15:14
There may be something in thesshd_config
that is forcing ownership change, or perhaps asetuid
andsetgid
bit is set on a directory above the one you are uploading to (this will also force ownership change).
– ivanivan
Dec 24 '18 at 15:30
What is the output ofssh -i xxx.pem sutya@publicipaddress ls -lnd . filename
? Unix stores the ownership of a file as a numeric value, andls
consults things like the password file to translate them to names. Ifec2-user
andsurya
have the same number then as far as file ownership is concerned they are the same user (they can have different passwords etc)
– icarus
Dec 25 '18 at 17:31
What meaning are you attaching to “Preferring”? Are those two commands on the same machine?
– ctrl-alt-delor
Dec 24 '18 at 10:46
What meaning are you attaching to “Preferring”? Are those two commands on the same machine?
– ctrl-alt-delor
Dec 24 '18 at 10:46
Is your "ls" output from running ls on the remote system, or the local system? Did "filename" already exist on the remote system before you ran scp?
– Kenster
Dec 24 '18 at 15:14
Is your "ls" output from running ls on the remote system, or the local system? Did "filename" already exist on the remote system before you ran scp?
– Kenster
Dec 24 '18 at 15:14
There may be something in the
sshd_config
that is forcing ownership change, or perhaps a setuid
and setgid
bit is set on a directory above the one you are uploading to (this will also force ownership change).– ivanivan
Dec 24 '18 at 15:30
There may be something in the
sshd_config
that is forcing ownership change, or perhaps a setuid
and setgid
bit is set on a directory above the one you are uploading to (this will also force ownership change).– ivanivan
Dec 24 '18 at 15:30
What is the output of
ssh -i xxx.pem sutya@publicipaddress ls -lnd . filename
? Unix stores the ownership of a file as a numeric value, and ls
consults things like the password file to translate them to names. If ec2-user
and surya
have the same number then as far as file ownership is concerned they are the same user (they can have different passwords etc)– icarus
Dec 25 '18 at 17:31
What is the output of
ssh -i xxx.pem sutya@publicipaddress ls -lnd . filename
? Unix stores the ownership of a file as a numeric value, and ls
consults things like the password file to translate them to names. If ec2-user
and surya
have the same number then as far as file ownership is concerned they are the same user (they can have different passwords etc)– icarus
Dec 25 '18 at 17:31
add a comment |
1 Answer
1
active
oldest
votes
The scp
command doesn't preserve owner and group for copied files.
For this purpose you can use the next commands:
rsync
command with--owner (or -o)
and--group(or -g)
options.
Fromman
:-o, --owner preserve owner (super-user only)
-g, --group preserve group- or
tar
coomand:tar --owner=user --group=user -cpf - ./* | ssh -l user dest_server
'tar xpf - -C /path/to/folder'
1
If I understand the question correctly, it's not about preserving ownership, but that the file is created as owned by the remoteec2-user
(no matter who the local owner is), even when the remote user issurya
, and notec2-user
. Which likely means something on the remote host is enforcing this, whatever it is. Which likely meansrsync
will run into the same enforcement.
– dirkt
Dec 25 '18 at 11:39
add a comment |
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
);
);
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%2funix.stackexchange.com%2fquestions%2f490721%2fneed-to-prefer-file-ownership-while-uploading-through-scp%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
The scp
command doesn't preserve owner and group for copied files.
For this purpose you can use the next commands:
rsync
command with--owner (or -o)
and--group(or -g)
options.
Fromman
:-o, --owner preserve owner (super-user only)
-g, --group preserve group- or
tar
coomand:tar --owner=user --group=user -cpf - ./* | ssh -l user dest_server
'tar xpf - -C /path/to/folder'
1
If I understand the question correctly, it's not about preserving ownership, but that the file is created as owned by the remoteec2-user
(no matter who the local owner is), even when the remote user issurya
, and notec2-user
. Which likely means something on the remote host is enforcing this, whatever it is. Which likely meansrsync
will run into the same enforcement.
– dirkt
Dec 25 '18 at 11:39
add a comment |
The scp
command doesn't preserve owner and group for copied files.
For this purpose you can use the next commands:
rsync
command with--owner (or -o)
and--group(or -g)
options.
Fromman
:-o, --owner preserve owner (super-user only)
-g, --group preserve group- or
tar
coomand:tar --owner=user --group=user -cpf - ./* | ssh -l user dest_server
'tar xpf - -C /path/to/folder'
1
If I understand the question correctly, it's not about preserving ownership, but that the file is created as owned by the remoteec2-user
(no matter who the local owner is), even when the remote user issurya
, and notec2-user
. Which likely means something on the remote host is enforcing this, whatever it is. Which likely meansrsync
will run into the same enforcement.
– dirkt
Dec 25 '18 at 11:39
add a comment |
The scp
command doesn't preserve owner and group for copied files.
For this purpose you can use the next commands:
rsync
command with--owner (or -o)
and--group(or -g)
options.
Fromman
:-o, --owner preserve owner (super-user only)
-g, --group preserve group- or
tar
coomand:tar --owner=user --group=user -cpf - ./* | ssh -l user dest_server
'tar xpf - -C /path/to/folder'
The scp
command doesn't preserve owner and group for copied files.
For this purpose you can use the next commands:
rsync
command with--owner (or -o)
and--group(or -g)
options.
Fromman
:-o, --owner preserve owner (super-user only)
-g, --group preserve group- or
tar
coomand:tar --owner=user --group=user -cpf - ./* | ssh -l user dest_server
'tar xpf - -C /path/to/folder'
answered Dec 25 '18 at 7:10
Gintoki
1
1
1
If I understand the question correctly, it's not about preserving ownership, but that the file is created as owned by the remoteec2-user
(no matter who the local owner is), even when the remote user issurya
, and notec2-user
. Which likely means something on the remote host is enforcing this, whatever it is. Which likely meansrsync
will run into the same enforcement.
– dirkt
Dec 25 '18 at 11:39
add a comment |
1
If I understand the question correctly, it's not about preserving ownership, but that the file is created as owned by the remoteec2-user
(no matter who the local owner is), even when the remote user issurya
, and notec2-user
. Which likely means something on the remote host is enforcing this, whatever it is. Which likely meansrsync
will run into the same enforcement.
– dirkt
Dec 25 '18 at 11:39
1
1
If I understand the question correctly, it's not about preserving ownership, but that the file is created as owned by the remote
ec2-user
(no matter who the local owner is), even when the remote user is surya
, and not ec2-user
. Which likely means something on the remote host is enforcing this, whatever it is. Which likely means rsync
will run into the same enforcement.– dirkt
Dec 25 '18 at 11:39
If I understand the question correctly, it's not about preserving ownership, but that the file is created as owned by the remote
ec2-user
(no matter who the local owner is), even when the remote user is surya
, and not ec2-user
. Which likely means something on the remote host is enforcing this, whatever it is. Which likely means rsync
will run into the same enforcement.– dirkt
Dec 25 '18 at 11:39
add a comment |
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.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- 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.
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%2funix.stackexchange.com%2fquestions%2f490721%2fneed-to-prefer-file-ownership-while-uploading-through-scp%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
What meaning are you attaching to “Preferring”? Are those two commands on the same machine?
– ctrl-alt-delor
Dec 24 '18 at 10:46
Is your "ls" output from running ls on the remote system, or the local system? Did "filename" already exist on the remote system before you ran scp?
– Kenster
Dec 24 '18 at 15:14
There may be something in the
sshd_config
that is forcing ownership change, or perhaps asetuid
andsetgid
bit is set on a directory above the one you are uploading to (this will also force ownership change).– ivanivan
Dec 24 '18 at 15:30
What is the output of
ssh -i xxx.pem sutya@publicipaddress ls -lnd . filename
? Unix stores the ownership of a file as a numeric value, andls
consults things like the password file to translate them to names. Ifec2-user
andsurya
have the same number then as far as file ownership is concerned they are the same user (they can have different passwords etc)– icarus
Dec 25 '18 at 17:31