Adding SSH Keys to CloneZilla disk-image

Create working-directory in root’s homdir:

root@Voyager:~# mkdir my-clonezilla
root@Voyager:~# cd my-clonezilla/
root@Voyager:~/my-clonezilla# 

Generate SSH Keys:

root@Voyager:~/my-clonezilla# ssh-keygen -t rsa -f ./id_rsa
Generating public/private rsa key pair.
Enter passphrase (empty for no passphrase): 
Enter same passphrase again: 
Your identification has been saved in ./id_rsa.
Your public key has been saved in ./id_rsa.pub.
The key fingerprint is:
SHA256:YcOXhcGKgm8MPQWPqdY7FzgLvn1/B+CaFn9Az+WOTgU root@Voyager
The key's randomart image is:
+---[RSA 2048]----+
|    ..   ..o.    |
|     +..  oo     |
|   oo...=.E      |
|  oo+...++ ..    |
|  +++o.oS+ o.    |
| o .++..o +..    |
|  ..+ .= ..+     |
|   o o= ..+ o    |
|  . .o ..+..     |
+----[SHA256]-----+
root@Voyager:~/my-clonezilla#

Mount USB Stick, copy image and unsquash it:

root@Voyager:~/my-clonezilla# mount /dev/sdc1 /mnt/usb/
root@Voyager:~/my-clonezilla# cp /mnt/usb/live/filesystem.squashfs .
root@Voyager:~/my-clonezilla# unsquashfs filesystem.squashfs 
Parallel unsquashfs: Using 4 processors
29605 inodes (29764 blocks) to write

[=================================================================\] 29764/29764 100%

created 25458 files
created 4104 directories
created 4115 symlinks
created 9 devices
created 0 fifos

Add your keys to the images homedir skeleton:

root@Voyager:~/my-clonezilla# mkdir squashfs-root/etc/skel/.ssh
root@Voyager:~/my-clonezilla# cp id_rsa* squashfs-root/etc/skel/.ssh/

Repack then squashfs:

root@Voyager:~/my-clonezilla# mksquashfs squashfs-root filesystem-new.squashfs -b 1024k -comp xz -Xbcj x86 -e boot 
Parallel mksquashfs: Using 4 processors
Creating 4.0 filesystem on filesystem-new.squashfs, block size 1048576.
[=========================================================================================/] 25641/25641 100%

Exportable Squashfs 4.0 filesystem, xz compressed, data block size 1048576
  compressed data, compressed metadata, compressed fragments, compressed xattrs
  duplicates are removed
Filesystem size 205942.03 Kbytes (201.12 Mbytes)
  23.13% of uncompressed filesystem size (890527.03 Kbytes)
Inode table size 262474 bytes (256.32 Kbytes)
  23.50% of uncompressed inode table size (1117024 bytes)
Directory table size 293876 bytes (286.99 Kbytes)
  41.90% of uncompressed directory table size (701431 bytes)
Xattr table size 78 bytes (0.08 Kbytes)
  97.50% of uncompressed xattr table size (80 bytes)
Number of duplicate files found 1938
Number of inodes 33688
Number of files 25459
Number of fragments 609
Number of symbolic links  4115
Number of device nodes 9
Number of fifo nodes 0
Number of socket nodes 0
Number of directories 4105
Number of ids (unique uids + gids) 16
Number of uids 4
  root (0)
  syslog (104)
  www-data (33)
  messagebus (106)
Number of gids 14
  root (0)
  dip (30)
  adm (4)
  shadow (42)
  nogroup (65534)
  utmp (43)
  tty (5)
  crontab (107)
  messagebus (110)
  syslog (108)
  staff (50)
  uuidd (111)
  www-data (33)
  mail (8)

Copy the new image in place, and unmount the image:

root@Voyager:~/my-clonezilla# cp filesystem-new.squashfs /mnt/usb/live/filesystem.squashfs 
root@Voyager:~/my-clonezilla# umount /mnt/usb 

 

Dette indlæg blev udgivet i Linux. Bogmærk permalinket.