I have a problem which is reproducible on Linux Ubuntu VMs (14.04 LTS) created in Azure.
After installing systemd
package through script, the system refuses new ssh connections, infinitely.
System is booting up.
Connection closed by xxx.xxx.xxx.xxx
The active ssh connection is maintained though. There is no /etc/nologin
file present in the system.
The only option I see is a hard reset which solves the problem. But how do I avoid it?
Here is the script I am using:
#!/bin/bash
# Script input arguments
user=$1
server=$2
# Tell the shell to quote your variables to be eval-safe!
printf -v user_q '%q' "$user"
printf -v server_q '%q' "$server"
#
SECONDS=0
address="$user_q"@"$server_q"
function run {
ssh "$address" /bin/bash "$@"
}
run << SSHCONNECTION
# Enable autostartup
# systemd is required for the autostartup
sudo dpkg-query -W -f='${Status}' systemd 2>/dev/null | grep -c "ok installed" > /home/$user_q/systemd-check.txt
systemdInstalled=\$(cat /home/$user_q/systemd-check.txt)
if [[ \$systemdInstalled -eq 0 ]]; then
echo "Systemd is not currently installed. Installing..."
# install systemd
sudo apt-get update
sudo apt-get -y install systemd
else
echo "systemd is already installed. Skipping this step."
fi
SSHCONNECTION