E: openssh-server: subprocess installed post-removal script returned error exit status 1
Binary package hint: openssh-server
I received the following two errors when trying to reinstall ssh and openssh-server after removing [I].ssh[/I] from my ~, [I]sudo rm -rf /etc/ssh[/I] and removing both with synaptic:
E: openssh-server: subprocess installed post-installation script returned error exit status 2
E: ssh: dependency problems - leaving unconfigured
Should this concern me and if so how do I remedy it?
Release: 9.10
laeg@skyrocket:~$ apt-cache policy ssh
ssh:
Installed: 1:5.1p1-6ubuntu2
Candidate: 1:5.1p1-6ubuntu2
Version table:
*** 1:5.1p1-6ubuntu2 0
500 http://
100 /var/lib/
laeg@skyrocket:~$ apt-cache policy openssh-server
openssh-server:
Installed: 1:5.1p1-6ubuntu2
Candidate: 1:5.1p1-6ubuntu2
Version table:
*** 1:5.1p1-6ubuntu2 0
500 http://
100 /var/lib/
Question information
- Language:
- English Edit question
- Status:
- Solved
- For:
- Ubuntu openssh Edit question
- Assignee:
- No assignee Edit question
- Solved by:
- laeg
- Solved:
- Last query:
- Last reply:
Revision history for this message
|
#1 |
Thank you for taking the time to report this issue and helping to make Ubuntu better. Examining the information you have given us, this does not appear to be a bug report so we are closing it and converting it to a question in the support tracker. We appreciate the difficulties you are facing, but it would make more sense to raise problems you are having in the support tracker at https:/
Revision history for this message
|
#2 |
In above openssh-server package is not getting removed because of script error. Mostly these are shell script written using /bin/sh. These scripts called with -e option which means if not interactive, exit immediately if any untested command fails. The exit status of a command is considered to be explicitly tested if the command is used to control an if, elif, while, or until; or if the command is the left hand operand of an && or || operator. In short shell scripts will abort with an error if something fails. To fix this problem visit /var/lib/dpkg/info directory
$ cd /var/lib/dpkg/info
Now find out files in following format:
$ ls openssh-server.*
Should output something like openssh-
Now open each file and find out line that read as follows:
#/bin/sh -e
Replace with
#/bin/sh
Save and close all the files. Now run apt-get / dpkg command again to remove package:
# apt-get --purge remove openssh-server
Revision history for this message
|
#3 |
Thanks.
Only 3/4 of the files found with ls openssh-server.* contained #/bin/sh -e. I change them to #/bin/sh, saved and did a # apt-get --purge remove openssh-server
laeg@skyrocket:
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages were automatically installed and are no longer required:
libgconfmm-
Use 'apt-get autoremove' to remove them.
The following packages will be REMOVED:
openssh-server* ssh*
0 upgraded, 0 newly installed, 2 to remove and 3 not upgraded.
2 not fully installed or removed.
After this operation, 811kB disk space will be freed.
Do you want to continue [Y/n]? y
(Reading database ... 172201 files and directories currently installed.)
Removing ssh ...
Removing openssh-server ...
* Stopping OpenBSD Secure Shell server sshd [ OK ]
Purging configuration files for openssh-server ...
rmdir: failed to remove `/etc/ssh': No such file or directory
/usr/sbin/deluser: The user `sshd' does not exist.
Processing triggers for man-db ...
Processing triggers for ufw ...
Processing triggers for ureadahead ...
I then tried to reinstall using synaptic's GUI which returned the error once again:
E: openssh-server: subprocess installed post-installation script returned error exit status 2
E: ssh: dependency problems - leaving unconfigured
Revision history for this message
|
#4 |
Ok back in /var/lib/dpkg/info
Open openssh-
you see something like this
" rm -f /etc/ssh/
rm -f /etc/ssh/
rm -f /etc/ssh/
rm -f /etc/ssh/
rm -f /etc/ssh/
if which deluser >/dev/null 2>&1; then
fi
"
Remove this section, or comment it all out save that file and re-try!
Revision history for this message
|
#5 |
I removed all the -e again and commented out the section you outlined above before once again executing the purge command
laeg@skyrocket:
Reading package lists... Done
Building dependency tree
Reading state information... Done
Package openssh-server is not installed, so not removed
The following packages were automatically installed and are no longer required:
libgconfmm-
Use 'apt-get autoremove' to remove them.
0 upgraded, 0 newly installed, 0 to remove and 3 not upgraded.
and then trying to reinstall openssh-server
laeg@skyrocket:
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages were automatically installed and are no longer required:
libgconfmm-
Use 'apt-get autoremove' to remove them.
Suggested packages:
rssh molly-guard openssh-blacklist openssh-
The following NEW packages will be installed:
openssh-server
0 upgraded, 1 newly installed, 0 to remove and 3 not upgraded.
Need to get 0B/286kB of archives.
After this operation, 766kB of additional disk space will be used.
Preconfiguring packages ...
Selecting previously deselected package openssh-server.
(Reading database ... 172191 files and directories currently installed.)
Unpacking openssh-server (from .../openssh-
Processing triggers for ureadahead ...
Processing triggers for ufw ...
Processing triggers for man-db ...
Setting up openssh-server (1:5.1p1-6ubuntu2) ...
/var/lib/
dpkg: error processing openssh-server (--configure):
subprocess installed post-installation script returned error exit status 2
Errors were encountered while processing:
openssh-server
E: Sub-process /usr/bin/dpkg returned an error code (1)
and then trying to reinstall ssh:
laeg@skyrocket:
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages were automatically installed and are no longer required:
libgconfmm-
Use 'apt-get autoremove' to remove them.
The following NEW packages will be installed:
ssh
0 upgraded, 1 newly installed, 0 to remove and 3 not upgraded.
1 not fully installed or removed.
Need to get 0B/1,252B of archives.
After this operation, 45.1kB of additional disk space will be used.
Selecting previously deselected package ssh.
(Reading database ... 172200 files and directories currently installed.)
Unpacking ssh (from .../ssh_
Setting up openssh-server (1:5.1p1-6ubuntu2) ...
/var/lib/
dpkg: error processing openssh-server (--configure):
subprocess installed post-installation script returned error exit status 2
dpkg: dependency problems prevent configuration of ssh:
ssh depends on openssh-server; however:
Package openssh-server is not configured yet.
dpkg: error processing ssh (--configure):
dependency problems - leaving unconfigured
No apport report written because the error message indicates its a followup error from a previous failure.
openssh-server
ssh
E: Sub-process /usr/bin/dpkg returned an error code (1)
Revision history for this message
|
#7 |
It does mention a missing dir /etc/ssh which I removed at the very start so:
laeg@skyrocket:
laeg@skyrocket:
Reading package lists... Done
Building dependency tree
Reading state information... Done
openssh-server is already the newest version.
openssh-server set to manually installed.
The following packages were automatically installed and are no longer required:
libgconfmm-
Use 'apt-get autoremove' to remove them.
0 upgraded, 0 newly installed, 0 to remove and 3 not upgraded.
2 not fully installed or removed.
After this operation, 0B of additional disk space will be used.
Setting up openssh-server (1:5.1p1-6ubuntu2) ...
Creating SSH2 RSA key; this may take some time ...
Creating SSH2 DSA key; this may take some time ...
* Restarting OpenBSD Secure Shell server sshd [ OK ]
Setting up ssh (1:5.1p1-6ubuntu2) ...
laeg@skyrocket:
Reading package lists... Done
Building dependency tree
Reading state information... Done
ssh is already the newest version.
The following packages were automatically installed and are no longer required:
libgconfmm-
Use 'apt-get autoremove' to remove them.
0 upgraded, 0 newly installed, 0 to remove and 3 not upgraded.
I then tried to remove and re-add it with synaptic again and got the same two errors :(
Revision history for this message
|
#9 |
It's not okay, I tried to remove it with synaptic's GUI and got the same two errors...?
Revision history for this message
|
#10 |
It will do because its now overwritten /var/lib/
sudo dpkg-reconfigure openssh-server
Is ssh working now?
Revision history for this message
|
#11 |
laeg@skyrocket:~$ sudo dpkg-reconfigure openssh-server
[sudo] password for laeg:
/usr/sbin/
laeg@skyrocket:~$ sudo mkdir /etc/ssh
laeg@skyrocket:~$ cd /var/lib/dpkg/inf
bash: cd: /var/lib/dpkg/inf: No such file or directory
laeg@skyrocket:~$ cd /var/lib/dpkg/info
laeg@skyrocket:
openssh-
openssh-
openssh-server.list openssh-
laeg@skyrocket:
(nautilus:3269): Eel-CRITICAL **: eel_preferences
laeg@skyrocket:
[sudo] password for laeg:
laeg@skyrocket:
laeg@skyrocket:
laeg@skyrocket:
laeg@skyrocket:
laeg@skyrocket:
laeg@skyrocket:
E: Could not open lock file /var/lib/dpkg/lock - open (13: Permission denied)
E: Unable to lock the administration directory (/var/lib/dpkg/), are you root?
laeg@skyrocket:
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages will be REMOVED:
openssh-server* ssh*
0 upgraded, 0 newly installed, 2 to remove and 7 not upgraded.
2 not fully installed or removed.
After this operation, 811kB disk space will be freed.
Do you want to continue [Y/n]? y
(Reading database ... 172193 files and directories currently installed.)
Removing ssh ...
Removing openssh-server ...
* Stopping OpenBSD Secure Shell server sshd [ OK ]
Purging configuration files for openssh-server ...
Processing triggers for man-db ...
Processing triggers for ufw ...
Processing triggers for ureadahead ...
ureadahead will be reprofiled on next reboot
laeg@skyrocket:
Reading package lists... Done
Building dependency tree
Reading state information... Done
Package ssh is not installed, so not removed
0 upgraded, 0 newly installed, 0 to remove and 7 not upgraded.
laeg@skyrocket:
ssh: connect to host my.internet.ip port 22: Connection refused
laeg@skyrocket:
laeg 1668 0.0 0.0 5808 612 ? Ss 11:04 0:00 /usr/bin/ssh-agent /usr/bin/
laeg 3963 0.0 0.0 3040 800 pts/0 R+ 11:49 0:00 grep ssh
laeg@skyrocket:
E: Could not get lock /var/lib/dpkg/lock - open (11: Resource temporarily unavailable)
E: Unable to lock the administration directory (/var/lib/dpkg/), is another process using it?
laeg@skyrocket:
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following extra packages will be installed:
openssh-server
Suggested packages:
rssh molly-guard openssh-blacklist openssh-
The following NEW packages will be installed:
openssh-server ssh
0 upgraded, 2 newly installed, 0 to remove and 7 not upgraded.
Need to get 0B/287kB of archives.
After this operation, 811kB of additional disk space will be used.
Do you want to continue [Y/n]? y
Preconfiguring packages ...
Selecting previously deselected package openssh-server.
(Reading database ... 172178 files and directories currently installed.)
Unpacking openssh-server (from .../openssh-
Selecting previously deselected package ssh.
Unpacking ssh (from .../ssh_
Processing triggers for ureadahead ...
Processing triggers for ufw ...
Processing triggers for man-db ...
Setting up openssh-server (1:5.1p1-6ubuntu2) ...
Creating SSH2 RSA key; this may take some time ...
Creating SSH2 DSA key; this may take some time ...
* Restarting OpenBSD Secure Shell server sshd [ OK ]
Setting up ssh (1:5.1p1-6ubuntu2) ...
laeg@skyrocket:
Reading package lists... Done
Building dependency tree
Reading state information... Done
openssh-server is already the newest version.
openssh-server set to manually installed.
0 upgraded, 0 newly installed, 0 to remove and 7 not upgraded.
laeg@skyrocket:
The authenticity of host 'my.internet.ip (my.internet.ip)' can't be established.
RSA key fingerprint is x:x:x:x:x:x etc etc
Are you sure you want to continue connecting (yes/no)? y
Please type 'yes' or 'no': yes
Warning: Permanently added 'my.internet.ip' (RSA) to the list of known hosts.
<email address hidden>'s password:
Linux skyrocket 2.6.31-16-generic #53-Ubuntu SMP Tue Dec 8 04:01:29 UTC 2009 i686
To access official Ubuntu documentation, please visit:
http://
Last login: Tue Dec 8 17:15:16 2009 from remote.host.ip
laeg@skyrocket:~$ exit
logout
Connection to my.internet.ip closed.
laeg@skyrocket:
Thanks, fixed :)
Revision history for this message
|
#13 |
I saw something similar in the 21.04 to 21.10 upgrade, i'll enter new issue 11/5/2021.
troubleshooting steps:
top - 23:36:07 up 1:19, 3 users, load average: 1.17, 1.14, 1.12
Tasks: 190 total, 2 running, 187 sleeping, 0 stopped, 1 zombie
%Cpu(s): 0.1 us, 25.6 sy, 0.0 ni, 74.3 id, 0.0 wa, 0.0 hi, 0.0 si, 0.0 st
MiB Mem : 1845.6 total, 97.4 free, 363.0 used, 1385.2 buff/cache
MiB Swap: 4095.9 total, 4047.4 free, 48.5 used. 1308.1 avail Mem
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
48256 root 20 0 2284 136 0 R 99.7 0.0 36:33.07 ucf
48471 root 20 0 11908 3384 2804 R 1.3 0.2 0:00.13 top
ps -ef | grep dpkg
root 17505 6341 0 22:53 pts/1 00:00:02 /usr/bin/dpkg --force-overwrite --status-fd 64 --configure --pending
root 17506 17505 0 22:53 pts/1 00:00:00 sh -c (test -x /usr/lib/
root 17507 17506 0 22:53 pts/1 00:00:00 sh -c (test -x /usr/lib/
root 17508 17507 0 22:53 pts/1 00:00:00 /bin/sh /usr/lib/
root 48228 17505 0 22:59 pts/1 00:00:00 /usr/bin/perl -w /usr/share/
root 48242 48228 0 22:59 pts/1 00:00:00 /bin/sh /var/lib/
root 48390 48381 0 23:25 pts/3 00:00:00 grep dpkg
kill -1 48242
kill -9 48242
kill -9 48228
then it contineud the upgrade..