自动确认 Linux 更新/升级

自动确认 Linux 更新/升级

我们为每个用户创建了一个在 Ubuntu 20.04.2 LTS (Focal Fossa) 上运行的数字海洋服务器。每隔几个月,这个过程就会卡住一次,因为更新中的某些内容需要 Y 或 Yes 等。我们一直在寻找新的方法来处理“自动说是”,但每隔几个月,似乎就会出现一个我们还没有处理的新问题。

我们现在的更新命令是:yes Y | sudo apt-get dist-upgrade -qq -y

我们最近一站是:

Configuring openssh-server
--------------------------

A new version (/tmp/fileJQ04gT) of configuration file /etc/ssh/sshd_config is 
available, but the version installed currently has been locally modified.

  1. install the package maintainer's version
  2. keep the local version currently installed
  3. show the differences between the versions
  4. show a side-by-side difference between the versions
  5. show a 3-way difference between available versions
  6. do a 3-way merge between available versions
  7. start a new shell to examine the situation

What do you want to do about modified configuration file sshd_config

这是自动对更新中的所有问题说“是”的方法吗(或者只是默默更新)?

答案1

超级用户帖子 非交互式 apt 升级 建议使用这个脚本:

DEBIAN_FRONTEND=noninteractive \
  apt-get \
  -o Dpkg::Options::=--force-confold \
  -o Dpkg::Options::=--force-confdef \
  -y --allow-downgrades --allow-remove-essential --allow-change-held-packages

您还可以考虑使用该unattended-upgrades软件包自动且无人值守地下载和安装安全升级。有关更多信息,请参阅有关它的众多文章之一: 如何在 Ubuntu Server 18.04 或 20.04 上设置自动更新

答案2

我在尝试为 ubuntu 20.04 自动安装 cassandra 时遇到了与 sshd_config 完全相同的问题

A new version (/tmp/filekTzYtV) 
of configuration file /etc/ssh/sshd_config is available, 
but the version installed currently has been locally   │      │ modified.

解决方案:

sudo DEBIAN_FRONTEND=noninteractive apt-get -yq upgrade

####绕过交互式提示的完整 Cassandra 安装脚本####

sudo apt-get update -y
sudo DEBIAN_FRONTEND=noninteractive apt-get -yq upgrade
apt-get install openjdk-8-jdk -y
java -version
apt-get install apt-transport-https gnupg2 -y
wget -q -O - https://www.apache.org/dist/cassandra/KEYS | apt-key add -
sh -c 'echo "deb http://www.apache.org/dist/cassandra/debian 311x main" > /etc/apt/sources.list.d/cassandra.list'
apt-get update -y
apt-get install cassandra -y
systemctl status cassandra

相关内容