Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 391
  • Last Modified:

Remove sudo

Ive built myself a little ubuntu server which works great, my only problem is editing config files.

I want to be able to edit files via winscp remotely, however when I try and save back I get 'access denied'. The only way Ive been able to edit the files is to use putty and then edit the files as sudo like "sudo nano /etc/apache2/httpd.conf".

Is it possible to take ownership of the entire server as my username so I can edit the files as I want without sudo through winscp, or through putty but without sudo?

Thank you in advance
0
tonelm54
Asked:
tonelm54
1 Solution
 
Jan SpringerCommented:
sudo su

you'll be asked for your password and at that point you're operating as root.
0
 
serialbandCommented:
You shouldn't do that, and you shouldn't disable sudo.  It's unnecessary.

Put your key in ~root/.ssh/authorized_keys if your sshd.conf doesn't block root.  The default ubuntu just prevents password access to root not ssh key access.  From the context, I'm assuming you're using ubuntu or it's variant, since you're talking about sudo.  They only blank the root password in /etc/shadow, but not actually restrict root from ssh access.  Don't set a password, because that allows for man-in-the-middle attacks.  That's been the default for quite some time on ubuntu.

Since you're using winscp & putty, you should learn to use pagent.exe to load and store your passphrased key to simplify your putty and winscp connections.  pagent is one of the tools included in putty.zip.

sudo su works, but sudo -s is the way to obtain sudo shell access.  You could technically restrict the su and bash commands, but still access the shell.  By default, ubuntu "admin" accounts have full sudo access.
0
 
tonelm54Author Commented:
My attemp here is to edit config files remotely and using nano isn't the easiest to use through putty. I thought editing the files through winscp would be easiest, however when editing I just get access denied when saving the files back.

I've never even heard of pageant, but from my understanding it's just used to store keys for connections which isn't my problem. I can connect fine to the server, it's just editing the files I'm stuck with :-(
0
 
TintinCommented:
In order to do what you want, you'll need to connect via WinSCP with the 'root' user.
0
 
serialbandCommented:
You use pagent to load the ssh key to connect to the root account.  To prevent man-in-the-middle attacks, you shouldn't use passwords for root.  Use ssh keys.  When you have the key in pagent, you can connect as root and edit/copy files with root permission.
0

Featured Post

NFR key for Veeam Backup for Microsoft Office 365

Veeam is happy to provide a free NFR license (for 1 year, up to 10 users). This license allows for the non‑production use of Veeam Backup for Microsoft Office 365 in your home lab without any feature limitations.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now