LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Server (https://www.linuxquestions.org/questions/linux-server-73/)
-   -   Cannot edit sshd_config as root (https://www.linuxquestions.org/questions/linux-server-73/cannot-edit-sshd_config-as-root-510959/)

LOLobo 12-16-2006 01:11 AM

Cannot edit sshd_config as root
 
Code:

[ Cannot open file for writing: Permission denied ]
Receiving this message in pico (and something similar in vim) when trying to save after having edited /etc/ssh/sshd_config.

I had edited and saved it before and added an extra listening port, however, noticed recently that the extra port was no longer working, and no longer was reflected in the sshd_config, also notice the date on the file remained that of date which it was last successfully edited.

Code:

ls -lh /etc/ssh/
total 148K
-rw-r--r--  1 root root 110K 2004-04-23 15:00 moduli
-rw-r--r--  1 root root 1.4K 2004-04-23 15:00 ssh_config
-rw-------  1 root root  672 2005-05-16 22:43 ssh_host_dsa_key
-rw-r--r--  1 root root  604 2005-05-16 22:43 ssh_host_dsa_key.pub
-rw-------  1 root root  529 2005-05-16 22:43 ssh_host_key
-rw-r--r--  1 root root  333 2005-05-16 22:43 ssh_host_key.pub
-rw-------  1 root root  887 2005-05-16 22:43 ssh_host_rsa_key
-rw-r--r--  1 root root  224 2005-05-16 22:43 ssh_host_rsa_key.pub
-rw-r--r--  1 root root 3.0K 2006-09-06 10:29 sshd_config

Please advise. I cannot delete, edit, or overwrite this file, however I can create new files in the same directory, and edit those. I'd prefer to not have sshd utilize a different config file. I want to successfully edit and save this file.

fvu 12-16-2006 01:49 AM

Are you sure you're editing the file as root, like in: sudo vim /etc/ssh/sshd_config?

Freddy Vulto
http://fvue.nl

LOLobo 12-16-2006 12:09 PM

This:
Code:

sudo vim /etc/ssh/sshd_config
Is resulting in this:
Code:

/etc/ssh/sshd_config" E212: Can't open file for writing

LOLobo 12-16-2006 02:15 PM

Figured it out by reading other posts on this same forum....
lsattr & chattr (which I've only previously used in eggdrops)

Code:

root@localhost:/etc/ssh# lsattr
su--ia------- ./sshd_config
------------- ./moduli
------------- ./ssh_host_key
su--ia------- ./ssh_config
------------- ./ssh_host_key.pub
------------- ./ssh_host_dsa_key
------------- ./ssh_host_dsa_key.pub
------------- ./ssh_host_rsa_key
------------- ./ssh_host_rsa_key.pub
------------- ./sshd_config_new

Code:

root@localhost:/etc/ssh# chattr -V -ia sshd_config
chattr 1.35 (28-Feb-2004)
Flags of sshd_config set as su-----------

Code:

root@localhost:/etc/ssh# lsattr
su----------- ./sshd_config
------------- ./moduli
------------- ./ssh_host_key
su--ia------- ./ssh_config
------------- ./ssh_host_key.pub
------------- ./ssh_host_dsa_key
------------- ./ssh_host_dsa_key.pub
------------- ./ssh_host_rsa_key
------------- ./ssh_host_rsa_key.pub
------------- ./sshd_config_new

Code:

root@localhost:~# chattr -V +ia /etc/ssh/sshd_config
chattr 1.35 (28-Feb-2004)
Flags of /etc/ssh/sshd_config set as su--ia-------



All times are GMT -5. The time now is 04:40 PM.