I am trying to remotely edit sshd_config file using WinSCP and putty. Unfortunately, I keep getting the following error-

“Cannot overwrite remote file Press delete to delete the file and create a new one”.

I tried deleting, but I got a similar error. I also tried changing the permissions on the file, but I got the error -

cannot change properties of file sshd_config.

I suspect I don't have the correct permissions, but I'm not sure what to do. I've attached a pic of my permissions below.

sshd_config file permissions


What do I need to do to be able to overwrite sshd_config ? Is it to do with my current permissions?

2 Answers 2


Editing config files on Windows and transfering them back to Linux is dangerous because Windows uses different line breaks than Linux.

You should rather edit the file directly on the remote machine by typing sudo nano /etc/ssh/sshd_config make your changes and press CTRL+O to save and CTRL+X to exit. This way you also don't have to care about permissions cause you are already root.

  • I hadn't know about that-thanks. Fortuantely, it seems that there may be some ways around that stackoverflow.com/questions/1967361/…
    – TryHarder
    Commented Aug 18, 2013 at 4:39
  • 1
    Sure. There is always a workaround for a workaround ;). But I'd recommend you to learn how to work directly on Linux commandline. It is very powerful and you'll love it after a while!
    – Germar
    Commented Aug 18, 2013 at 18:37

The answer actually turned out to be pretty obvious. I'm new to linux, so I was confused. When I logged into the server using the username and pw that I used to install the server, I was under the misunderstanding that this was the same as being root.

Anyway, I didn't have the correct permissions to edit the file, so to fix it I used Putty to ssh into the server then I created a new group called editors with the following code

sudo addgroup editors 

then I added my user to that group

sudo adduser myusername editors

Next I gave the group editors ownership of the directory

sudo chown :editors /etc/ssh/

Next I changed the file permissions such that the group could write to the folder

sudo chmod 770 /etc/ssh

After logging back into the server again with WinSCP I was able to edit the files in the directory.

This may not be the recommended way of going about this- if it isn't I'd appreciate someone letting me know :)

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .