You try to upgrade OpenSSH on Debian/Ubuntu (packages openssh-client and openssh-server) and get the following errors:

Unpacking replacement openssh-server ...
dpkg: error processing /var/cache/apt/archives/openssh-server_1%3a5.5p1-6_amd64.deb (--unpack):
unable to make backup link of `./usr/sbin/sshd' before installing new version: Operation not permitted
configured to not write apport reports
Preparing to replace openssh-client 1:5.1p1-5 (using .../openssh-client_1%3a5.5p1-6_amd64.deb) ...
Unpacking replacement openssh-client ...
dpkg: error processing /var/cache/apt/archives/openssh-client_1%3a5.5p1-6_amd64.deb (--unpack):
unable to make backup link of `./usr/bin/ssh' before installing new version: Operation not permitted

 

Solution

(We need root permissions for this, so if you are on Ubuntu, run

sudo su

first to become root.)

Check the attributes of /usr/bin/ssh:

lsattr /usr/bin/ssh

[email protected]:~# lsattr /usr/bin/ssh
su--ia------------ /usr/bin/ssh
[email protected]:~#

If you see the attributes i and a, remove them both:

chattr -i /usr/bin/ssh
chattr -a /usr/bin/ssh

If you just see i or a, remove just the one you see.

Now do the same again for /usr/bin/sshd:

lsattr /usr/bin/sshd

[email protected]:~# lsattr /usr/bin/sshd
su--ia------------ /usr/bin/sshd
[email protected]:~#

If you see the attributes i and a, remove them both:

chattr -i /usr/bin/sshd
chattr -a /usr/bin/sshd

If you just see i or a, remove just the one you see.

Then try the upgrade again.

Falko Timme

About Falko Timme

Falko Timme is an experienced Linux administrator and founder of Timme Hosting, a leading nginx business hosting company in Germany. He is one of the most active authors on HowtoForge since 2005 and one of the core developers of ISPConfig since 2000. He has also contributed to the O'Reilly book "Linux System Administration".

Share this page:

Suggested articles

3 Comment(s)

Add comment

Comments

By: Anonymous

Although my ssh file was located at /usr/bin/ssh, my sshd file was nowhere to be found. 

I ended up discovering that it was actually in the /sbin/ file.

If you run into a similar problem simply run the same commands except on the /sbin/ folder:

chattr -i /usr/sbin/sshd 

chattr -a /usr/sbin/sshd

By: JokinAU

Hi!

Google brought me here. This post was very useful for me, in my case with the error: unable to make backup link of `./usr/lib/php5/sessionclean' before installing new version: Operation not permitted

I just had to:

chattr -i /usr/lib/php5/sessionclean

chattr -a /usr/lib/php5/sessionclean

chattr +s /usr/lib/php5/sessionclean

chattr +u /usr/lib/php5/sessionclean

And it fixed my problem! Thanks a lot

By: Milani

Thanks you.

Problem solved here.