1

I want to install 30 stations with Ubuntu Desktop in a lab, to which I can later connect via ssh. I figured it was OK to install them in OEM mode, install all the necessary applications on them, then clone the installation and replicate the 30 stations. I understand that the OEM mode is like sysprep for Windows, it removes any duplicate ID so after I finish copying the clones on the stations go into "normal" working mode.

Can install in OEM mode ssh server before moving to the installation in user mode? In other words, if in user mode then ssh will work.

This is the output of "/tmp/ssh-serv.hygbC", after when I tryed to install "openssh-server" at reboot time with "crontab"

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 -----
  • 3
    It is not clear what you are asking. Clearly state what you did, what you expected to happen, and what happened including copied and pasted (and formatted as code) error messages. What is ok or correct for me may not be ok for you. – user68186 Nov 26 '19 at 14:20
  • An ssh server or an ssh client? – user535733 Nov 26 '19 at 14:26
  • In this site it is best to update the question with the new information using the edit question feature. Otherwise the question will be closed. – user68186 Nov 27 '19 at 21:33
  • The ssh client programs are already there in a standard Ubuntu desktop system, so I conclude, that you mean installing ssh server programs. I use the package 'openssh-server` for that purpose, and I think it is OK to install it into your OEM system. I think it should work at least with password authentication. You may want key authentication, and I am not sure it that will also work, because I have only done it with single computers (not OEM systems). Let us hope someone who knows more about networks and security can chip in and help you. – sudodus Nov 28 '19 at 8:19
  • 1
    Yesterday I installed Xubuntu in OEM mode in the virtual box. Then I installed openssh-server, I cloned the virtual machine,then I ran "prepare for shipping" and then once installed the 2 virtual machines I connected through ssh from one to the other and vice versa. I found that the keys were identical on both machines, which I didn't think was right. I uninstalled openssh-server on a machine with the option purge (apt-get purge openssh-server) and then reinstalled it on this machine. This time when I connected by ssh the keys on the 2 machines were different. – sergiareddu Nov 29 '19 at 7:46
0

To include openssh-server in an OEM installation

The ssh client programs are already there in a standard Ubuntu desktop system, so I conclude, that you mean installing ssh server programs. I use the package openssh-server for that purpose, and I think it is OK to install it into your OEM system.

I think it should work at least with password authentication. You may want key authentication, and I am not sure it that will also work, because I have only done it with single computers (not OEM systems).

Yesterday I installed Xubuntu in OEM mode in the virtual box. Then I installed openssh-server, I cloned the virtual machine,then I ran "prepare for shipping" and then once installed the 2 virtual machines I connected through ssh from one to the other and vice versa. I found that the keys were identical on both machines, which I didn't think was right. I uninstalled openssh-server on a machine with the option purge (apt-get purge openssh-server) and then reinstalled it on this machine. This time when I connected by ssh the keys on the 2 machines were different.

You want different keys for the ssh server, and you have found that it will not work with OEM. Maybe you can put installation of openssh-server into sudo crontab at reboot so that it will be configured automatically, when a user starts the final configuration.

How to install openssh-server via crontab

Create a shellscript with full paths.

#!/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
  • I included also some echo commands in order to help debugging. You can remove them if you wish.
  • I started with a delay so that other parts of the environment will get ready, for example the network. You should have wired network (ethernet) with internet access for this kind of installation to work.
  • You may want to remove the shellscript /crontabber and the line from crontab after it has done its job, but it is not necessary.

Edit an @reboot line into crontab for root

sudo crontab -e

The file should look like this,

# 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

Looking at the logfile in the directory 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
$ 

Links

You can find good tutorials about `crontab' via the internet via the search string 'crontab tutorial' (without quotes), for example

Finally, the following link is added for readers, who have not yet learned about Ubuntu OEM systems.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.