-
-
Notifications
You must be signed in to change notification settings - Fork 5.9k
Add ssh certificate support #12281
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
Merged
Merged
Add ssh certificate support #12281
Changes from all commits
Commits
Show all changes
47 commits
Select commit
Hold shift + click to select a range
60fb3ed
Add ssh certificate support
42wim 2dcb3f8
Add ssh certificate support to builtin ssh
42wim 4cacc44
Write trusted-user-ca-keys.pem based on configuration
42wim 3e928d0
Update app.example.ini
42wim 8d9989a
Update templates/user/settings/keys_principal.tmpl
42wim d5e5a40
Remove unused locale string
42wim cd27073
Update options/locale/locale_en-US.ini
42wim 0ade115
Update options/locale/locale_en-US.ini
42wim 8defaaf
Update models/ssh_key.go
42wim 2f10d27
Add missing creation of SSH.Rootpath
42wim 3a198e4
Update cheatsheet, example and locale strings
42wim 1d0dea8
Update models/ssh_key.go
42wim 3e39a5c
Update models/ssh_key.go
42wim 63b6bc9
Update models/ssh_key.go
42wim c27e664
Update models/ssh_key.go
42wim aedeac0
Update models/ssh_key.go
zeripath 8f492ff
Optimizations based on feedback
42wim eacedf5
Validate CA keys for external sshd
42wim 2e73472
Add filename option and change default filename
42wim b0ac111
Remove unneeded principalkey functions
42wim 0f88094
Add blank line
42wim 455982a
Apply suggestions from code review
42wim 9ebfffd
Add SSH_AUTHORIZED_PRINCIPALS_ALLOW option
42wim b63e231
Rewrite principal keys file on user deletion
42wim 6a16067
Merge branch 'master' into certificates
lafriks 6c65bb1
Use correct rewrite method
42wim aa2c19f
Set correct AuthorizedPrincipalsBackup default setting
42wim 27f64d0
Rewrite principalsfile when adding principals
42wim 86f3af6
Add update authorized_principals option to admin dashboard
42wim 5c03b58
Merge remote-tracking branch 'origin/master' into 42wim-certificates
zeripath a0d356d
Handle non-primary emails
zeripath c46bb5f
Add the command actually to the dashboard template
42wim ce8487a
Update models/ssh_key.go
techknowlogick bc03f3a
Merge branch 'master' into certificates
techknowlogick fc5fa28
Merge remote-tracking branch 'origin/master' into 42wim-certificates
zeripath 012dfda
By default do not show principal options unless there are CA keys set…
zeripath 98b8447
allow settings when enabled
techknowlogick e767b63
Merge branch 'master' into certificates
techknowlogick d9f8713
Fix typos in TrustedUserCAKeys path
42wim 1e3352d
Allow every CASignatureAlgorithms algorithm
42wim 5f42f3a
Update models/ssh_key.go
42wim 66b99f7
Merge branch 'master' into certificates
42wim 91d0d5b
Fix linting issue
42wim 8711842
Merge branch 'master' into certificates
zeripath 108a65e
Merge branch 'master' into certificates
zeripath 0efcab0
Merge remote-tracking branch 'origin/master' into 42wim-certificates
zeripath 9a896de
Merge branch 'master' into certificates
techknowlogick File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
This file contains hidden or 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 |
---|---|---|
|
@@ -297,6 +297,9 @@ SSH_ROOT_PATH = | |
; Gitea will create a authorized_keys file by default when it is not using the internal ssh server | ||
; If you intend to use the AuthorizedKeysCommand functionality then you should turn this off. | ||
SSH_CREATE_AUTHORIZED_KEYS_FILE = true | ||
; Gitea will create a authorized_principals file by default when it is not using the internal ssh server | ||
; If you intend to use the AuthorizedPrincipalsCommand functionality then you should turn this off. | ||
SSH_CREATE_AUTHORIZED_PRINCIPALS_FILE = true | ||
; For the built-in SSH server, choose the ciphers to support for SSH connections, | ||
; for system SSH this setting has no effect | ||
SSH_SERVER_CIPHERS = aes128-ctr, aes192-ctr, aes256-ctr, [email protected], arcfour256, arcfour128 | ||
|
@@ -312,7 +315,26 @@ SSH_KEY_TEST_PATH = | |
; Path to ssh-keygen, default is 'ssh-keygen' which means the shell is responsible for finding out which one to call. | ||
SSH_KEYGEN_PATH = ssh-keygen | ||
; Enable SSH Authorized Key Backup when rewriting all keys, default is true | ||
SSH_BACKUP_AUTHORIZED_KEYS = true | ||
SSH_AUTHORIZED_KEYS_BACKUP = true | ||
; Determines which principals to allow | ||
; - empty: if SSH_TRUSTED_USER_CA_KEYS is empty this will default to off, otherwise will default to email, username. | ||
; - off: Do not allow authorized principals | ||
; - email: the principal must match the user's email | ||
; - username: the principal must match the user's username | ||
; - anything: there will be no checking on the content of the principal | ||
SSH_AUTHORIZED_PRINCIPALS_ALLOW = email, username | ||
; Enable SSH Authorized Principals Backup when rewriting all keys, default is true | ||
SSH_AUTHORIZED_PRINCIPALS_BACKUP = true | ||
; Specifies the public keys of certificate authorities that are trusted to sign user certificates for authentication. | ||
42wim marked this conversation as resolved.
Show resolved
Hide resolved
|
||
; Multiple keys should be comma separated. | ||
; E.g."ssh-<algorithm> <key>". or "ssh-<algorithm> <key1>, ssh-<algorithm> <key2>". | ||
; For more information see "TrustedUserCAKeys" in the sshd config manpages. | ||
SSH_TRUSTED_USER_CA_KEYS = | ||
42wim marked this conversation as resolved.
Show resolved
Hide resolved
|
||
; Absolute path of the `TrustedUserCaKeys` file gitea will manage. | ||
; Default this `RUN_USER`/.ssh/gitea-trusted-user-ca-keys.pem | ||
; If you're running your own ssh server and you want to use the gitea managed file you'll also need to modify your | ||
; sshd_config to point to this file. The official docker image will automatically work without further configuration. | ||
SSH_TRUSTED_USER_CA_KEYS_FILENAME = | ||
; Enable exposure of SSH clone URL to anonymous visitors, default is false | ||
SSH_EXPOSE_ANONYMOUS = false | ||
; Indicate whether to check minimum key size with corresponding type | ||
|
This file contains hidden or 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 |
---|---|---|
|
@@ -13,6 +13,9 @@ HostKey /data/ssh/ssh_host_ecdsa_key | |
HostKey /data/ssh/ssh_host_dsa_key | ||
|
||
AuthorizedKeysFile .ssh/authorized_keys | ||
AuthorizedPrincipalsFile .ssh/authorized_principals | ||
TrustedUserCAKeys /data/git/.ssh/gitea-trusted-user-ca-keys.pem | ||
CASignatureAlgorithms ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521,[email protected],ssh-ed25519,[email protected],rsa-sha2-512,rsa-sha2-256,ssh-rsa | ||
|
||
UseDNS no | ||
AllowAgentForwarding no | ||
|
This file contains hidden or 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 |
---|---|---|
|
@@ -251,6 +251,11 @@ Values containing `#` or `;` must be quoted using `` ` `` or `"""`. | |
- `SSH_LISTEN_PORT`: **%(SSH\_PORT)s**: Port for the built-in SSH server. | ||
- `SSH_ROOT_PATH`: **~/.ssh**: Root path of SSH directory. | ||
- `SSH_CREATE_AUTHORIZED_KEYS_FILE`: **true**: Gitea will create a authorized_keys file by default when it is not using the internal ssh server. If you intend to use the AuthorizedKeysCommand functionality then you should turn this off. | ||
- `SSH_TRUSTED_USER_CA_KEYS`: **\<empty\>**: Specifies the public keys of certificate authorities that are trusted to sign user certificates for authentication. Multiple keys should be comma separated. E.g.`ssh-<algorithm> <key>` or `ssh-<algorithm> <key1>, ssh-<algorithm> <key2>`. For more information see `TrustedUserCAKeys` in the sshd config man pages. When empty no file will be created and `SSH_AUTHORIZED_PRINCIPALS_ALLOW` will default to `off`. | ||
- `SSH_TRUSTED_USER_CA_KEYS_FILENAME`: **`RUN_USER`/.ssh/gitea-trusted-user-ca-keys.pem**: Absolute path of the `TrustedUserCaKeys` file gitea will manage. If you're running your own ssh server and you want to use the gitea managed file you'll also need to modify your sshd_config to point to this file. The official docker image will automatically work without further configuration. | ||
- `SSH_AUTHORIZED_PRINCIPALS_ALLOW`: **off** or **username, email**: \[off, username, email, anything\]: Specify the principals values that users are allowed to use as principal. When set to `anything` no checks are done on the principal string. When set to `off` authorized principal are not allowed to be set. | ||
- `SSH_CREATE_AUTHORIZED_PRINCIPALS_FILE`: **false/true**: Gitea will create a authorized_principals file by default when it is not using the internal ssh server and `SSH_AUTHORIZED_PRINCIPALS_ALLOW` is not `off`. | ||
- `SSH_AUTHORIZED_PRINCIPALS_BACKUP`: **false/true**: Enable SSH Authorized Principals Backup when rewriting all keys, default is true if `SSH_AUTHORIZED_PRINCIPALS_ALLOW` is not `off`. | ||
- `SSH_SERVER_CIPHERS`: **aes128-ctr, aes192-ctr, aes256-ctr, [email protected], arcfour256, arcfour128**: For the built-in SSH server, choose the ciphers to support for SSH connections, for system SSH this setting has no effect. | ||
- `SSH_SERVER_KEY_EXCHANGES`: **diffie-hellman-group1-sha1, diffie-hellman-group14-sha1, ecdh-sha2-nistp256, ecdh-sha2-nistp384, ecdh-sha2-nistp521, [email protected]**: For the built-in SSH server, choose the key exchange algorithms to support for SSH connections, for system SSH this setting has no effect. | ||
- `SSH_SERVER_MACS`: **[email protected], hmac-sha2-256, hmac-sha1, hmac-sha1-96**: For the built-in SSH server, choose the MACs to support for SSH connections, for system SSH this setting has no effect | ||
|
This file contains hidden or 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
This file contains hidden or 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.