Need to prefer file ownership while uploading through scp

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












1














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.










share|improve this question























  • 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 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















1














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.










share|improve this question























  • 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 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













1












1








1







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.










share|improve this question















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






share|improve this question















share|improve this question













share|improve this question




share|improve this question








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 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 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 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 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










1 Answer
1






active

oldest

votes


















-1














The scp command doesn't preserve owner and group for copied files.

For this purpose you can use the next commands:




  1. rsync command with --owner (or -o) and --group(or -g) options.

    From man:
    -o, --owner preserve owner (super-user only)
    -g, --group preserve group


  2. or tar coomand:
    tar --owner=user --group=user -cpf - ./* | ssh -l user dest_server
    'tar xpf - -C /path/to/folder'






share|improve this answer
















  • 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










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%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









-1














The scp command doesn't preserve owner and group for copied files.

For this purpose you can use the next commands:




  1. rsync command with --owner (or -o) and --group(or -g) options.

    From man:
    -o, --owner preserve owner (super-user only)
    -g, --group preserve group


  2. or tar coomand:
    tar --owner=user --group=user -cpf - ./* | ssh -l user dest_server
    'tar xpf - -C /path/to/folder'






share|improve this answer
















  • 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















-1














The scp command doesn't preserve owner and group for copied files.

For this purpose you can use the next commands:




  1. rsync command with --owner (or -o) and --group(or -g) options.

    From man:
    -o, --owner preserve owner (super-user only)
    -g, --group preserve group


  2. or tar coomand:
    tar --owner=user --group=user -cpf - ./* | ssh -l user dest_server
    'tar xpf - -C /path/to/folder'






share|improve this answer
















  • 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













-1












-1








-1






The scp command doesn't preserve owner and group for copied files.

For this purpose you can use the next commands:




  1. rsync command with --owner (or -o) and --group(or -g) options.

    From man:
    -o, --owner preserve owner (super-user only)
    -g, --group preserve group


  2. or tar coomand:
    tar --owner=user --group=user -cpf - ./* | ssh -l user dest_server
    'tar xpf - -C /path/to/folder'






share|improve this answer












The scp command doesn't preserve owner and group for copied files.

For this purpose you can use the next commands:




  1. rsync command with --owner (or -o) and --group(or -g) options.

    From man:
    -o, --owner preserve owner (super-user only)
    -g, --group preserve group


  2. or tar coomand:
    tar --owner=user --group=user -cpf - ./* | ssh -l user dest_server
    'tar xpf - -C /path/to/folder'







share|improve this answer












share|improve this answer



share|improve this answer










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 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












  • 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







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

















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.





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.




draft saved


draft discarded














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





















































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?