Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change SSH key generation instructions to use the Ed25519 algorithm #940

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 17 additions & 9 deletions content/admin/enterprise-management/monitoring-cluster-nodes.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,26 +33,34 @@ You can configure [Nagios](https://www.nagios.org/) to monitor {% data variables
#### Configuring the Nagios host
1. Generate an SSH key with a blank passphrase. Nagios uses this to authenticate to the {% data variables.product.prodname_ghe_server %} cluster.
```shell
nagiosuser@nagios:~$ <em>ssh-keygen -t rsa -b 4096</em>
> Generating public/private rsa key pair.
> Enter file in which to save the key (/home/nagiosuser/.ssh/id_rsa):
nagiosuser@nagios:~$ <em>ssh-keygen -t ed25519</em>
> Generating public/private ed25519 key pair.
> Enter file in which to save the key (/home/nagiosuser/.ssh/id_ed25519):
> Enter passphrase (empty for no passphrase): <em>leave blank by pressing enter</em>
> Enter same passphrase again: <em>press enter again</em>
> Your identification has been saved in /home/nagiosuser/.ssh/id_rsa.
> Your public key has been saved in /home/nagiosuser/.ssh/id_rsa.pub.
> Your identification has been saved in /home/nagiosuser/.ssh/id_ed25519.
> Your public key has been saved in /home/nagiosuser/.ssh/id_ed25519.pub.
```
{% danger %}

**Security Warning:** An SSH key without a passphrase can pose a security risk if authorized for full access to a host. Limit this key's authorization to a single read-only command.

{% enddanger %}
2. Copy the private key (`id_rsa`) to the `nagios` home folder and set the appropriate ownership.
{% note %}

**Note:** If you're using a distribution of Linux that doesn't support the Ed25519 algorithm, use the command:
```shell
nagiosuser@nagios:~$ ssh-keygen -t rsa -b 4096
```

{% endnote %}
2. Copy the private key (`id_ed25519`) to the `nagios` home folder and set the appropriate ownership.
```shell
nagiosuser@nagios:~$ <em>sudo cp .ssh/id_rsa /var/lib/nagios/.ssh/</em>
nagiosuser@nagios:~$ <em>sudo chown nagios:nagios /var/lib/nagios/.ssh/id_rsa</em>
nagiosuser@nagios:~$ <em>sudo cp .ssh/id_ed25519 /var/lib/nagios/.ssh/</em>
nagiosuser@nagios:~$ <em>sudo chown nagios:nagios /var/lib/nagios/.ssh/id_ed25519</em>
```

3. To authorize the public key to run *only* the `ghe-cluster-status -n` command, use a `command=` prefix in the `/data/user/common/authorized_keys` file. From the administrative shell on any node, modify this file to add the public key generated in step 1. For example: `command="/usr/local/bin/ghe-cluster-status -n" ssh-rsa AAAA....`
3. To authorize the public key to run *only* the `ghe-cluster-status -n` command, use a `command=` prefix in the `/data/user/common/authorized_keys` file. From the administrative shell on any node, modify this file to add the public key generated in step 1. For example: `command="/usr/local/bin/ghe-cluster-status -n" ssh-ed25519 AAAA....`

4. Validate and copy the configuration to each node in the cluster by running `ghe-cluster-config-apply` on the node where you modified the `/data/user/common/authorized_keys` file.

Expand Down
16 changes: 8 additions & 8 deletions content/admin/policies/creating-a-pre-receive-hook-script.md
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,8 @@ You can test a pre-receive hook script locally before you create or update it on
adduser git -D -G root -h /home/git -s /bin/bash && \
passwd -d git && \
su git -c "mkdir /home/git/.ssh && \
ssh-keygen -t rsa -b 4096 -f /home/git/.ssh/id_rsa -P '' && \
mv /home/git/.ssh/id_rsa.pub /home/git/.ssh/authorized_keys && \
ssh-keygen -t ed25519 -f /home/git/.ssh/id_ed25519 -P '' && \
mv /home/git/.ssh/id_ed25519.pub /home/git/.ssh/authorized_keys && \
mkdir /home/git/test.git && \
git --bare init /home/git/test.git"

Expand Down Expand Up @@ -136,17 +136,17 @@ You can test a pre-receive hook script locally before you create or update it on
> Sending build context to Docker daemon 3.584 kB
> Step 1 : FROM gliderlabs/alpine:3.3
> ---> 8944964f99f4
> Step 2 : RUN apk add --no-cache git openssh bash && ssh-keygen -A && sed -i "s/#AuthorizedKeysFile/AuthorizedKeysFile/g" /etc/ssh/sshd_config && adduser git -D -G root -h /home/git -s /bin/bash && passwd -d git && su git -c "mkdir /home/git/.ssh && ssh-keygen -t rsa -b 4096 -f /home/git/.ssh/id_rsa -P ' && mv /home/git/.ssh/id_rsa.pub /home/git/.ssh/authorized_keys && mkdir /home/git/test.git && git --bare init /home/git/test.git"
> Step 2 : RUN apk add --no-cache git openssh bash && ssh-keygen -A && sed -i "s/#AuthorizedKeysFile/AuthorizedKeysFile/g" /etc/ssh/sshd_config && adduser git -D -G root -h /home/git -s /bin/bash && passwd -d git && su git -c "mkdir /home/git/.ssh && ssh-keygen -t ed25519 -f /home/git/.ssh/id_ed25519 -P ' && mv /home/git/.ssh/id_ed25519.pub /home/git/.ssh/authorized_keys && mkdir /home/git/test.git && git --bare init /home/git/test.git"
> ---> Running in e9d79ab3b92c
> fetch http://alpine.gliderlabs.com/alpine/v3.3/main/x86_64/APKINDEX.tar.gz
> fetch http://alpine.gliderlabs.com/alpine/v3.3/community/x86_64/APKINDEX.tar.gz
....truncated output....
> OK: 34 MiB in 26 packages
> ssh-keygen: generating new host keys: RSA DSA ECDSA ED25519
> Password for git changed by root
> Generating public/private rsa key pair.
> Your identification has been saved in /home/git/.ssh/id_rsa.
> Your public key has been saved in /home/git/.ssh/id_rsa.pub.
> Generating public/private ed25519 key pair.
> Your identification has been saved in /home/git/.ssh/id_ed25519.
> Your public key has been saved in /home/git/.ssh/id_ed25519.pub.
....truncated output....
> Initialized empty Git repository in /home/git/test.git/
> Successfully built dd8610c24f82
Expand Down Expand Up @@ -174,7 +174,7 @@ You can test a pre-receive hook script locally before you create or update it on
9. Copy the generated SSH key from the data container to the local machine:

```shell
$ docker cp data:/home/git/.ssh/id_rsa .
$ docker cp data:/home/git/.ssh/id_ed25519 .
```

10. Modify the remote of a test repository and push to the `test.git` repo within the Docker container. This example uses `[email protected]:octocat/Hello-World.git` but you can use any repo you want. This example assumes your local machine (127.0.0.1) is binding port 52311, but you can use a different IP address if docker is running on a remote machine.
Expand All @@ -183,7 +183,7 @@ You can test a pre-receive hook script locally before you create or update it on
$ git clone [email protected]:octocat/Hello-World.git
$ cd Hello-World
$ git remote add test [email protected]:test.git
$ GIT_SSH_COMMAND="ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -p 52311 -i ../id_rsa" git push -u test main
$ GIT_SSH_COMMAND="ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -p 52311 -i ../id_ed25519" git push -u test main
> Warning: Permanently added '[192.168.99.100]:52311' (ECDSA) to the list of known hosts.
> Counting objects: 7, done.
> Delta compression using up to 4 threads.
Expand Down