Monday, April 29, 2024
 Popular · Latest · Hot · Upcoming
155
rated 0 times [  155] [ 0]  / answers: 1 / hits: 451210  / 1 Year ago, wed, december 28, 2022, 7:54:39

I have an Ubuntu server to which I am connecting using SSH.



I need to upload files from my machine into /var/www/ on the server, the files in /var/www/ are owned by root.



Using PuTTY, after I log in, I have to type sudo su and my password first in order to be able to modify files in /var/www/.



But when I am copying files using WinSCP , I can't create create/modify files in /var/www/, because the user I'm connecting with does not have permissions on files in /var/www/ and I can't say sudo su as I do in case of an ssh session.



Do you know how i could deal with this ?



If I was working on my local machine, I would call gksudo nautilus but in this case I only have terminal access to the machine.


More From » server

 Answers
0

You're right, there is no sudo when working with scp. A workaround is to use scp to upload files to a directory where your user has permissions to create files, then log in via ssh and use sudo to move/copy files to their final destination.



scp -r folder/ [email protected]:/some/folder/you/dont/need/sudo
ssh [email protected]
$ sudo mv /some/folder /some/folder/requiring/perms
# YOU MAY NEED TO CHANGE THE OWNER like:
# sudo chown -R user:user folder


Another solution would be to change permissions/ownership of the directories you uploading the files to, so your non-privileged user is able to write to those directories.



Generally, working in the root account should be an exception, not a rule - the way you phrasing your question makes me think maybe you're abusing it a bit, which in turn leads to problems with permissions - under normal circumstances you don't need super-admin privileges to access your own files.



Technically, you can configure Ubuntu to allow remote login directly as root, but this feature is disabled for a reason, so I would strongly advice you against doing that.


[#34606] Thursday, December 29, 2022, 1 Year  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
enincroscope

Total Points: 252
Total Questions: 124
Total Answers: 104

Location: Tajikistan
Member since Thu, Apr 14, 2022
2 Years ago
;