-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
new: add ssh private key mdata option for root user
We would like to store the public and private ssh key for the root user in mdata. This allow us to have that information after reprovision a zone. The only valid key must be an rsa key and the public key ist mostly not required by the system.
- Loading branch information
Showing
2 changed files
with
28 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 20 additions & 0 deletions
20
copy/opt/core/var/mdata-setup/includes/02-root-ssh-keys.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
#!/bin/bash | ||
# Configure ssh public and private key for root user in mdata variable | ||
|
||
if mdata-get root_ssh_rsa 1>/dev/null 2>&1; then | ||
mkdir -p /root/.ssh | ||
echo "# This file is managed by mdata-get root_ssh_rsa" \ | ||
> /root/.ssh/id_rsa | ||
mdata-get root_ssh_rsa >> /root/.ssh/id_rsa | ||
|
||
# Mostly not required but we only support it with privat key | ||
if mdata-get root_ssh_rsa_pub 1>/dev/null 2>&1; then | ||
echo "# This file is managed by mdata-get root_ssh_rsa_pub" \ | ||
> /root/.ssh/id_rsa.pub | ||
mdata-get root_ssh_rsa_pub >> /root/.ssh/id_rsa.pub | ||
fi | ||
|
||
# Set correct permissions | ||
chmod 700 /root/.ssh | ||
chmod 600 /root/.ssh/id_rsa* | ||
fi |