skip to Main Content

recently I met one troublesome problem with my lab ubuntu server. I want to reinstall my openssh server, so I run the command

sudo apt-get install openssh-client
sudo apt-get install openssh-server

However, the command failed with the feedback

Unpacking replacement openssh-server ... 
 dpkg: error processing /var/cache/apt/archives/openssh-server_1%3a7.6p1-4ubuntu0.3_amd64.deb (--unpack): 
 unable to make backup link of `./usr/sbin/sshd' before installing new version: Operation not permitted 

According to one feasible solution(https://www.howtoforge.com/debian-ubuntu-unable-to-make-backup-link-of-usr-bin-sshd-before-installing-new-version-operation-not-permitted), it said that we should check the attribute of my /usr/bin/ssh and /usr/bin/sshd with chattr and lsattr command. But when I ran

sudo lsattr /usr/bin/ssh
sudo chattr /usr/bin/ssh

,it came no any output. And it seems that my lsattr/chattr command is wrong cause I check the size of lsattr and chattr, there are 10576 b and 10592 b in my other ubuntu server. But in this server, ther are only 10 b. And if I use less -SN lsattr/chattr, they all show:

#!/bin/sh
/usr/bin/chattr (END)
#!/bin/sh
/usr/bin/lsattr (END)

And if I want to replace (with root) those chattr and lsattr with the one I copy from other server, it shows Operation not permitted

So anyone could help me with this openssh problem or reintall chattr/lsattr?

2

Answers


  1. I recently experienced the same problem as you. All your previous actions are correct. But Before replacing lsattr and chattr, you need to modify the attributes of /usr/bin/lsattr and /usr/bin/chattr using the copied chattr.

    sudo ./chattr -a -i /usr/bin/chattr
    sudo ./chattr -a -i /usr/bin/lsattr
    

    Then the replacement operation can be performed and you can modify the attributes of /usr/sbin/sshd.

    sudo mv ./lsattr /usr/bin/lsattr 
    sudo mv ./chattr /usr/bin/chattr 
    sudo chattr -a -i /usr/sbin/sshd
    

    Then you can try to install openssh.
    To be on the safe side, finally add the ai attribute to both the replaced lsattr and chattr.

    sudo chattr +a +i /usr/bin/chattr
    sudo chattr +a +i /usr/bin/lsattr
    
    Login or Signup to reply.
  2. I came across this problem, too.

    Normally, the /usr/bin/lsattr file should be a binary executable, but I found it to be empty (with only one line #!/bin/sh).

    This case, maybe we should not fix the problem by copying the correct /usr/bin/lsattr binary from another computer, but we should be aware that our computers are attacked!

    The file /usr/bin/lsattr is replaced, and the ./usr/sbin/sshd executable is modified, which means that the ssh is not secure any more! Attackers can log in to your computer, and take over the control. Any private information is not secure any more……

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search