Skip to content

Commit 51b58fc

Browse files
authored
Merge pull request #1936 from fluxcd/azure-devops-ssh-update
Update Azure DevOps docs with RSA SHA-2 keys
2 parents 51b0f1b + 3bd92ae commit 51b58fc

File tree

2 files changed

+72
-25
lines changed

2 files changed

+72
-25
lines changed

content/en/flux/installation/bootstrap/azure-devops.md

+52-18
Original file line numberDiff line numberDiff line change
@@ -51,29 +51,65 @@ inside the `flux-system` namespace.
5151

5252
{{% alert color="info" title="Token rotation" %}}
5353
Note that Azure DevOps PAT have an expiry date. To rotate the token before it expires,
54-
delete the `flux-system` secret from the cluster and re-run
55-
the bootstrap command using a valid PAT.
54+
delete the `flux-system` secret from the cluster and create a new one with the new PAT:
55+
56+
```sh
57+
flux create secret git flux-system \
58+
--url=https://dev.azure.com/<org>/<project>/_git/<repository> \
59+
--username=git \
60+
--password=<az-token>
61+
```
5662
{{% /alert %}}
5763

58-
If you want to avoid storing your PAT in the cluster, set `--ssh-hostname` and the Flux controllers will use SSH:
64+
## Bootstrap using SSH keys
5965

60-
```shell
61-
flux bootstrap git \
62-
--url=https://dev.azure.com/<org>/<project>/_git/<repository> \
63-
--branch=main \
64-
--password=${GIT_PASSWORD} \
65-
--ssh-hostname=ssh.dev.azure.com \
66-
--ssh-key-algorithm=rsa \
67-
--ssh-rsa-bits=4096 \
68-
--path=clusters/my-cluster
66+
Azure DevOps SSH works only with RSA SHA-2 keys.
67+
68+
To configure Flux with RSA SHA-2 keys, you need to clone the DevOps locally, then
69+
create the file structure required by bootstrap with:
70+
71+
```sh
72+
mkdir -p clusters/my-cluster/flux-system
73+
touch clusters/my-cluster/flux-system/gotk-components.yaml \
74+
clusters/my-cluster/flux-system/gotk-sync.yaml \
75+
clusters/my-cluster/flux-system/kustomization.yaml
6976
```
7077

71-
The bootstrap command will generate a new SSH private key for the cluster,
72-
and it will prompt you to add the SSH public key to your personal SSH keys.
78+
Edit the `kustomization.yaml` file to include the following patches:
79+
80+
```yaml
81+
apiVersion: kustomize.config.k8s.io/v1beta1
82+
kind: Kustomization
83+
resources:
84+
- gotk-components.yaml
85+
- gotk-sync.yaml
86+
patches:
87+
- patch: |
88+
- op: add
89+
path: /spec/template/spec/containers/0/args/-
90+
value: --ssh-hostkey-algos=rsa-sha2-512,rsa-sha2-256
91+
target:
92+
kind: Deployment
93+
name: (source-controller|image-automation-controller)
94+
```
95+
96+
Commit and push the changes to upstream with:
97+
98+
```sh
99+
git add -A && git commit -m "init flux" && git push
100+
```
73101

74-
## Bootstrap without a DevOps PAT
102+
To generate an SSH key pair compatible with
103+
Azure DevOps, you'll need to use `ssh-keygen` with the `rsa-sha2-512` algorithm:
75104

76-
To bootstrap using a SSH key instead of a Azure DevOps PAT, run:
105+
```sh
106+
ssh-keygen -t rsa-sha2-512
107+
```
108+
109+
Upload the SSH public key to Azure DevOps. For more information, see the
110+
[Azure DevOps documentation](https://learn.microsoft.com/en-us/azure/devops/repos/git/use-ssh-keys-to-authenticate?view=azure-devops#step-2-add-the-public-key-to-azure-devops).
111+
112+
Run bootstrap using the SSH URL of the Azure DevOps repository and the RSA SHA-2 private key:
77113

78114
```sh
79115
flux bootstrap git \
@@ -84,7 +120,5 @@ flux bootstrap git \
84120
--path=clusters/my-cluster
85121
```
86122

87-
**Note** that you must generate an SSH private key and set the public key to your personal SSH keys in advance.
88-
89123
For more information on how to use the `flux bootstrap git` command,
90124
please see the generic Git server [documentation](generic-git-server.md).

content/en/flux/installation/bootstrap/generic-git-server.md

+20-7
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,9 @@ delete the `flux-system` secret from the cluster and run:
4141
```shell
4242
flux create secret git flux-system \
4343
--url=ssh://git@<host>/<org>/<repository> \
44-
--ssh-key-algorithm=rsa \
45-
--ssh-rsa-bits=4096
44+
--private-key-file=<path/to/private.key> \
45+
--password=<key-passphrase>
4646
```
47-
48-
The CLI will prompt you to add the SSH public key as a deploy key to your repository.
4947
{{% /alert %}}
5048

5149
## SSH Agent
@@ -72,6 +70,20 @@ and it will prompt you to add the SSH public key as a deploy key to your reposit
7270

7371
The generated SSH key defaults to `ECDSA P-384`, to change the format use `--ssh-key-algorithm` and `--ssh-ecdsa-curve`.
7472

73+
{{% alert color="info" title="SSH Key rotation" %}}
74+
To regenerate the SSH private key and known hosts keys,
75+
delete the `flux-system` secret from the cluster and run:
76+
77+
```shell
78+
flux create secret git flux-system \
79+
--url=ssh://git@<host>/<org>/<repository> \
80+
--ssh-key-algorithm=ecdsa \
81+
--ssh-ecdsa-curve=p384
82+
```
83+
84+
The CLI will prompt you to add the SSH public key as a deploy key to your repository.
85+
{{% /alert %}}
86+
7587
## HTTPS basic auth
7688

7789
If your Git server has basic auth enabled, you can bootstrap Flux over HTTPS with:
@@ -92,13 +104,14 @@ If your Git server uses a self-signed TLS certificate, you can specify the CA fi
92104

93105
## HTTPS authorization header
94106

95-
To access Git repositories that require a bearer token in the HTTP headers as an Authorization header such as [Oracle VBS Git Repositories](https://docs.oracle.com/en/cloud/paas/visual-builder/visualbuilder-manage-development-process/access-git-repository-using-token-based-authentication.html):
107+
To access Git repositories that require a bearer token in the HTTP headers
108+
as an Authorization header such as [Oracle VBS Git Repositories](https://docs.oracle.com/en/cloud/paas/visual-builder/visualbuilder-manage-development-process/access-git-repository-using-token-based-authentication.html):
96109

97110
```sh
98111
flux bootstrap git \
99-
--url=https://repository-url \
100-
--with-bearer-token \
112+
--url=https://<host>/<org>/<repository> \
101113
--password=<Access Token> \
114+
--with-bearer-token \
102115
--path=clusters/my-cluster
103116
```
104117

0 commit comments

Comments
 (0)