0

I am using Ubuntu 16LTS and performed a regular upgrade with apt. The upgrade failed with openssh-server and apt complained it could not upgrade because it cannot make a backup of /usr/sbin/sshd

I removed openssh-server and tried to reinstall it. No luck and apt comes back with the same message. I remove openssh-server again.

When I try to manually change or remove /usr/sbin/sshd I get the message that "Operation is not permitted". I tried to remove the attribute chattr -a -i /usr/sbin/sshd but it keeps responding that the operation not permitted. An other annoying issue is that lsattr does not give back any info.

How can I force a delete or move of the /usr/sbin/sshd file?

0

The following command will show you which process lock a specific file:

sudo lsof /usr/sbin/sshd

If the result of lsof will give you sshd service than you should stop the service before performing the upgrade.

Assuming the you tried to remove sshd while it is still running, you can try to stop sshd first.

Using:

sudo /etc/init.d/ssh stop

or

sudo service ssh stop

After the service is stopped, you can try to upgrade via apt or remove the folder manually.

  • When I run the lsof /usr/sbin/sshd command I do not get anything back. The sshd process is not running, so it could not lock the file. – Fred de Goede May 18 '17 at 9:23
  • @FreddeGoede - okay, so now the file is not locked. what happened when you try to execute the apt command (or move/delete the file)? – Yaron May 18 '17 at 9:26
  • When I execute the apt command it says it cannot install openssh-server because it cannot make a backup of /usr/sbin/sshd – Fred de Goede May 18 '17 at 9:32
  • When I try to delete it, it says "Operation not permitted" – Fred de Goede May 18 '17 at 9:32
0

I found the solution myself. Apearently the lsattr and chattr files where damaged. Maybe I was hacked. When I replaced the two files with the correct version I could remove the -i flag and I could remove sshd.

Thanks for the help Yaron.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.