Stop a running Linux VM and create a general-purpose template.
Ensure each VM started from it does not retain the source VM's host-specific identity.
Which preparation is most appropriate?
A template should not copy SSH host keys or /etc/machine-id unchanged. First-boot tooling should generate identity values for each clone.
Detailed explanation
Incorrect. Sharing MAC addresses causes network identity conflicts.
Incorrect. Sharing MAC addresses causes network identity conflicts.
Incorrect. A common persistent hostname does not make instances uniquely identifiable.
Incorrect. A common persistent hostname does not make instances uniquely identifiable.
Incorrect. Making the private key read-only still copies the same identity to every clone.
Incorrect. Making the private key read-only still copies the same identity to every clone.
Correct. SSH host keys and machine-id should be regenerated or initialized uniquely for each clone.
Correct. SSH host keys and machine-id should be regenerated or initialized uniquely for each clone.
Try it yourself
An example you can run in a temporary verification environment.
test -s /etc/machine-id && wc -c /etc/machine-id; find /etc/ssh -maxdepth 1 -name 'ssh_host_*_key' -printExpected result
稼働中ゲストではmachine-idとSSHホスト秘密鍵が存在する。削除や再生成は行わないKey points
- Do not share SSH host keys
- Make machine-id unique
- Generate identities on first boot
Notes
- Environment: systemd系Linux/OpenSSH
- Command output formatting can vary slightly by distribution or tool version.
- Run the example in a temporary directory or process when possible.
Foundation review
Read the scope first
Check whether the command acts on the current shell, a new process, an existing process, or a file.
Verify the observable result
Use the supplied command and compare the output with the expected result.