我想在实验室中安装 30 个带有 Ubuntu Desktop 的工作站,以后我可以通过 ssh 连接到这些工作站。我认为以 OEM 模式安装它们、在它们上安装所有必要的应用程序、然后克隆安装并复制这 30 个工作站是可以的。我理解 OEM 模式就像 Windows 的 sysprep,它会删除任何重复的 ID,因此在我完成复制后,工作站上的克隆将进入“正常”工作模式。
是否可以在转到用户模式安装之前先在 OEM 模式下安装 ssh 服务器?换句话说,如果在用户模式下,那么 ssh 就可以工作。
这是我在重启时使用“crontab”尝试安装“openssh-server”后“/tmp/ssh-serv.hygbC”的输出
sudo cat /tmp/ssh-serv.hygbC
[sudo] password for administrator:
----- after sleep -----
Eroare:1 http://security.ubuntu.com/ubuntu bionic-security InRelease
Eșec temporar la rezolvarea lui „security.ubuntu.com”
Eroare:2 http://ro.archive.ubuntu.com/ubuntu bionic InRelease
Eșec temporar la rezolvarea lui „ro.archive.ubuntu.com”
Eroare:3 http://ro.archive.ubuntu.com/ubuntu bionic-updates InRelease
Eșec temporar la rezolvarea lui „ro.archive.ubuntu.com”
Eroare:4 http://ro.archive.ubuntu.com/ubuntu bionic-backports InRelease
Eșec temporar la rezolvarea lui „ro.archive.ubuntu.com”
Citire liste de pachete...
Se construiește arborele de dependență...
Se citesc informațiile de stare...
2 packages can be upgraded. Run 'apt list --upgradable' to see them.
----- updated -----
Citire liste de pachete...
Se construiește arborele de dependență...
Se citesc informațiile de stare...
The following additional packages will be installed:
ncurses-term openssh-sftp-server ssh-import-id
Pachete sugerate:
molly-guard monkeysphere rssh ssh-askpass
Următoarele pachete NOI vor fi instalate:
ncurses-term openssh-server openssh-sftp-server ssh-import-id
0 înnoite, 4 nou instalate, 0 de șters și 2 neînnoite.
Este nevoie să descărcați 0 B/637 kB de arhive.
După această operație vor fi folosiți din disc încă 5.316 kB.
dpkg: avertisment: 'ldconfig' not found in PATH or not executable
dpkg: avertisment: 'start-stop-daemon' not found in PATH or not executable
dpkg: eroare: 2 expected programs not found in PATH or not executable
Note: root's PATH should usually contain /usr/local/sbin, /usr/sbin and /sbin
----- installed -----
答案1
包含openssh-server
在 OEM 安装中
ssh 客户端程序已存在于标准 Ubuntu 桌面系统中,因此我得出结论,您的意思是安装 ssh 服务器程序。我使用该软件包openssh-server
来实现此目的,我认为将其安装到您的 OEM 系统中是可以的。
我认为它至少应该适用于密码验证。你可能需要密钥验证,但我不确定它是否也能起作用,因为我只在单台计算机上做过(不是 OEM 系统)。
昨天我在虚拟机中以 OEM 模式安装了 Xubuntu。然后我安装了
openssh-server
,克隆了虚拟机,然后运行“准备发货”,然后安装了 2 台虚拟机,我通过 ssh 从一个连接到另一个,反之亦然。我发现两台机器上的密钥相同,我认为这不对。我openssh-server
在一台机器上使用 purge 选项(apt-get purge openssh-server)卸载了它,然后在这台机器上重新安装了它。这次当我通过 ssh 连接时,两台机器上的密钥不同。
您需要为 ssh 服务器设置不同的密钥,但您发现它无法与 OEM 配合使用。也许您可以在重启时将安装放入,openssh-server
这样sudo crontab
当用户启动最终配置时,它将自动配置。
如何openssh-server
安装crontab
创建一个具有完整路径的 shellscript。
#!/bin/bash
LANG=C # new
PATH="$PATH:/usr/local/sbin:/usr/sbin:/sbin" # new
tmpfil=$(mktemp /tmp/ssh-serv.XXXXX)
> $tmpfil
/usr/bin/sleep 30
echo '----- after sleep -----' >> $tmpfil
if ! test -f /usr/sbin/sshd
then
if /usr/bin/apt update | tee -a $tmpfil
then
echo '----- updated -----' >> $tmpfil
else
echo '----- update failed -----' >> $tmpfil
exit
fi
if /usr/bin/apt install -y openssh-server | tee -a $tmpfil
then
echo '----- installed -----' >> $tmpfil
else
echo '----- install failed -----' >> $tmpfil
fi
else
echo '----- skipped -----' >> $tmpfil
fi
- 我还添加了一些
echo
命令以帮助调试。您可以根据需要删除它们。 - 我开始延迟安装,以便环境的其他部分(例如网络)做好准备。要使此类安装正常工作,您应该拥有可访问互联网的有线网络(以太网)。
- 您可能希望在它完成其工作后删除 shellscript
/crontabber
和该行crontab
,但这不是必需的。
@reboot
在 crontab 中编辑一行root
sudo crontab -e
该文件看起来应该是这样的,
# Edit this file to introduce tasks to be run by cron.
#
# Each task to run has to be defined through a single line
# indicating with different fields when the task will be run
# and what command to run for the task
#
# To define the time you can provide concrete values for
# minute (m), hour (h), day of month (dom), month (mon),
# and day of week (dow) or use '*' in these fields (for 'any').
#
# Notice that tasks will be started based on the cron's system
# daemon's notion of time and timezones.
#
# Output of the crontab jobs (including errors) is sent through
# email to the user the crontab file belongs to (unless redirected).
#
# For example, you can run a backup of all your user accounts
# at 5 a.m every week with:
# 0 5 * * 1 tar -zcf /var/backups/home.tgz /home/
#
# For more information see the manual pages of crontab(5) and cron(8)
#
# m h dom mon dow command
@reboot /bin/bash /crontabber
查看目录中的日志文件tmp
$ sudo cat /tmp/ssh-serv.*
----- after sleep -----
Bra:1 http://se.archive.ubuntu.com/ubuntu focal InRelease
Bra:2 http://se.archive.ubuntu.com/ubuntu focal-updates InRelease
Bra:3 http://se.archive.ubuntu.com/ubuntu focal-backports InRelease
Bra:4 http://security.ubuntu.com/ubuntu focal-security InRelease
Läser paketlistor…
Bygger beroendeträd…
Läser tillståndsinformation…
1 paket kan uppgraderas. Kör ”apt list --upgradable” för att se det.
----- updated -----
Läser paketlistor…
Bygger beroendeträd…
Läser tillståndsinformation…
The following additional packages will be installed:
ncurses-term openssh-sftp-server ssh-import-id
Föreslagna paket:
molly-guard monkeysphere rssh ssh-askpass
Följande NYA paket kommer att installeras:
ncurses-term openssh-server openssh-sftp-server ssh-import-id
0 att uppgradera, 4 att nyinstallera, 0 att ta bort och 1 att inte uppgradera.
Behöver hämta 677 kB arkiv.
Efter denna åtgärd kommer ytterligare 6 026 kB utrymme användas på disken.
Läs:1 http://se.archive.ubuntu.com/ubuntu focal/main amd64 ncurses-term all 6.1+20191019-1ubuntu1 [249 kB]
Läs:2 http://se.archive.ubuntu.com/ubuntu focal/main amd64 openssh-sftp-server amd64 1:8.1p1-1 [51,2 kB]
Läs:3 http://se.archive.ubuntu.com/ubuntu focal/main amd64 openssh-server amd64 1:8.1p1-1 [365 kB]
Läs:4 http://se.archive.ubuntu.com/ubuntu focal/main amd64 ssh-import-id all 5.7-24-g4001a38e-0ubuntu1 [11,5 kB]
Hämtade 677 kB på 0s (2 342 kB/s)
Väljer tidigare ej valt paket ncurses-term.
(Läser databasen ... 165420 filer och kataloger installerade.)
Förbereder att packa upp .../ncurses-term_6.1+20191019-1ubuntu1_all.deb ...
Packar upp ncurses-term (6.1+20191019-1ubuntu1) ...
Väljer tidigare ej valt paket openssh-sftp-server.
Förbereder att packa upp .../openssh-sftp-server_1%3a8.1p1-1_amd64.deb ...
Packar upp openssh-sftp-server (1:8.1p1-1) ...
Väljer tidigare ej valt paket openssh-server.
Förbereder att packa upp .../openssh-server_1%3a8.1p1-1_amd64.deb ...
Packar upp openssh-server (1:8.1p1-1) ...
Väljer tidigare ej valt paket ssh-import-id.
Förbereder att packa upp .../ssh-import-id_5.7-24-g4001a38e-0ubuntu1_all.deb ...
Packar upp ssh-import-id (5.7-24-g4001a38e-0ubuntu1) ...
Ställer in openssh-sftp-server (1:8.1p1-1) ...
Ställer in openssh-server (1:8.1p1-1) ...
debconf: kan inte initiera framände: Dialog
debconf: (TERM är inte satt, så dialogframänden kan inte användas.)
debconf: faller tillbaka på framände: Readline
Creating config file /etc/ssh/sshd_config with new version
Creating SSH2 RSA key; this may take some time ...
3072 SHA256:N9OOuD1+OpPdWUpkrTWKKUfn0IeEbKwrzTkiLSGJQNc root@tester-Lenovo-V130-14IKB (RSA)
Creating SSH2 ECDSA key; this may take some time ...
256 SHA256:cwKjQfMmbagFA6t55PCUEJoVjydUmkMFmzH61wqr0KU root@tester-Lenovo-V130-14IKB (ECDSA)
Creating SSH2 ED25519 key; this may take some time ...
256 SHA256:rfWdoE3MFymrfHRW+U3rbVSmEzlbDSKUjue2l7bgWw4 root@tester-Lenovo-V130-14IKB (ED25519)
Created symlink /etc/systemd/system/sshd.service → /lib/systemd/system/ssh.service.
Created symlink /etc/systemd/system/multi-user.target.wants/ssh.service → /lib/systemd/system/ssh.service.
rescue-ssh.target is a disabled or a static unit, not starting it.
Ställer in ssh-import-id (5.7-24-g4001a38e-0ubuntu1) ...
Attempting to convert /etc/ssh/ssh_import_id
Ställer in ncurses-term (6.1+20191019-1ubuntu1) ...
Hanterar utlösare för systemd (243-3ubuntu1) ...
Hanterar utlösare för man-db (2.9.0-1) ...
Hanterar utlösare för ufw (0.36-1ubuntu3) ...
----- installed -----
tester@tester-Lenovo-V130-14IKB:~$ ps -A|grep ssh
1205 ? 00:00:00 ssh-agent
2125 ? 00:00:00 sshd
$
链接
您可以通过搜索字符串“crontab tutorial”(不带引号)在互联网上找到有关“crontab”的优秀教程,例如
最后,为那些还不了解 Ubuntu OEM 系统的读者添加了以下链接。