Compare commits
6 Commits
kvm-clones
...
keygen_2
| Author | SHA1 | Date | |
|---|---|---|---|
| 297c4a8459 | |||
| e217a003f2 | |||
| 1535a55316 | |||
| 67629ca840 | |||
| 9e9efba5c3 | |||
| ce332cd791 |
@@ -3,4 +3,82 @@
|
|||||||
*Prep*
|
*Prep*
|
||||||
Install the base OS.
|
Install the base OS.
|
||||||
Install all required apps
|
Install all required apps
|
||||||
Install all required updates
|
* openssh-server
|
||||||
|
Install all required updates
|
||||||
|
|
||||||
|
Shutdown guest
|
||||||
|
* virsh shotdown $guest-vm
|
||||||
|
|
||||||
|
|
||||||
|
On the VM Host server make sure you have libgustsfs-tools
|
||||||
|
|
||||||
|
```
|
||||||
|
apt list --installed |grep -i libguestfs-tools
|
||||||
|
```
|
||||||
|
|
||||||
|
if its not there, install it.
|
||||||
|
|
||||||
|
```
|
||||||
|
sudo apt install libguestfs-tools
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
This step strips stuff that must be unique per VM (machine-id, SSH keys, etc.) from the *template*.
|
||||||
|
|
||||||
|
```
|
||||||
|
sudo virt-sysprep -d $guest-vm \
|
||||||
|
--operations machine-id,ssh-hostkeys,udev-persistent-net,logfiles,tmp-files
|
||||||
|
```
|
||||||
|
|
||||||
|
Your output should be similiar to the following:
|
||||||
|
|
||||||
|
```
|
||||||
|
sudo virt-sysprep -d Debian-Base --operations machine-id,ssh-hostkeys,udev-persistent-net,logfiles,tmp-files
|
||||||
|
[ 0.0] Examining the guest ...
|
||||||
|
[ 17.4] Performing "logfiles" ...
|
||||||
|
[ 17.6] Performing "machine-id" ...
|
||||||
|
[ 17.6] Performing "ssh-hostkeys" ...
|
||||||
|
[ 17.6] Performing "tmp-files" ...
|
||||||
|
[ 17.6] Performing "udev-persistent-net" ...
|
||||||
|
```
|
||||||
|
|
||||||
|
The base is now ready to go.
|
||||||
|
|
||||||
|
**Create Clone**
|
||||||
|
|
||||||
|
sudo virt-clone --original $guest-vm \
|
||||||
|
--name guest-01 \
|
||||||
|
--auto-clone
|
||||||
|
|
||||||
|
example
|
||||||
|
|
||||||
|
```
|
||||||
|
sudo virt-clone --original Debian-Base \
|
||||||
|
--name Node01 \
|
||||||
|
--auto-clone
|
||||||
|
Allocating 'Node01.qcow2' | 1.6 GB 00:00:03 ...
|
||||||
|
|
||||||
|
Clone 'Node01' created successfully
|
||||||
|
```
|
||||||
|
|
||||||
|
Confirm your clones have been made
|
||||||
|
|
||||||
|
```
|
||||||
|
virsh list --all
|
||||||
|
Id Name State
|
||||||
|
---------------------------------
|
||||||
|
1 downloads running
|
||||||
|
- Debian-Base shut off
|
||||||
|
- k8s-node1 shut off
|
||||||
|
- k8s-node2 shut off
|
||||||
|
- k8s-node3 shut off
|
||||||
|
- k8s-node4 shut off
|
||||||
|
- k8s-node5 shut off
|
||||||
|
- Node01 shut off
|
||||||
|
- Node02 shut off
|
||||||
|
- Node03 shut off
|
||||||
|
- Node04 shut off
|
||||||
|
- Node05 shut off
|
||||||
|
- Ubuntu_Default shut off
|
||||||
|
|
||||||
|
```
|
||||||
53
SSH/keygen.md
Normal file
53
SSH/keygen.md
Normal file
@@ -0,0 +1,53 @@
|
|||||||
|
**SSH Key Gen**
|
||||||
|
After a fresh install we want to generate an SSH key pair (public and private)
|
||||||
|
we can then use this key to ssh onto hosts without having to share passwords.
|
||||||
|
|
||||||
|
On the new host
|
||||||
|
|
||||||
|
```
|
||||||
|
ssh-keygen -t ecdsa
|
||||||
|
```
|
||||||
|
|
||||||
|
You could add a -C for comment and then add your emaiul address but... meh
|
||||||
|
|
||||||
|
|
||||||
|
Example
|
||||||
|
|
||||||
|
```
|
||||||
|
~$ ssh-keygen -t ecdsa
|
||||||
|
Generating public/private ecdsa key pair.
|
||||||
|
Enter file in which to save the key (/home/luddie/.ssh/id_ecdsa):
|
||||||
|
Created directory '/home/luddie/.ssh'.
|
||||||
|
Enter passphrase for "/home/luddie/.ssh/id_ecdsa" (empty for no passphrase):
|
||||||
|
Enter same passphrase again:
|
||||||
|
Your identification has been saved in /home/luddie/.ssh/id_ecdsa
|
||||||
|
Your public key has been saved in /home/luddie/.ssh/id_ecdsa.pub
|
||||||
|
The key fingerprint is:
|
||||||
|
SHA256:gA+5oVKPdtlG7JQC5pL3NQ+OokUK7WoosTevWBCd1E0 luddie@debian-base
|
||||||
|
The key's randomart image is:
|
||||||
|
+---[ECDSA 256]---+
|
||||||
|
| +. oE |
|
||||||
|
| B o.+.. |
|
||||||
|
|= 1 * X |
|
||||||
|
|.O = / = |
|
||||||
|
|B = B * S |
|
||||||
|
|.X o . |
|
||||||
|
|*.+ |
|
||||||
|
|o+ o |
|
||||||
|
|. ... |
|
||||||
|
+----[SHA256]-----+
|
||||||
|
~$
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||
|
This will generate 2 keys in the .ssh folder
|
||||||
|
|
||||||
|
```
|
||||||
|
~/.ssh$ ls
|
||||||
|
id_ecdsa id_ecdsa.pub
|
||||||
|
~/.ssh$
|
||||||
|
```
|
||||||
|
|
||||||
|
Use can then cat the .pub file to get the public keyu for that host, which can be added to the authorized_host file of other machines to gain access.
|
||||||
|
|
||||||
|
You can also create an authorized_keys on your cost, and add other ssh pub key to allow them to have direct access to this host.
|
||||||
Reference in New Issue
Block a user