Skip to content

Commit ee0fbdd

Browse files
committed
Allow adding SSH keys even if SSH server is disabled
This is useful in case you want to use them for signature verification. A notice is added to avoid confusion.
1 parent 55d93fe commit ee0fbdd

File tree

3 files changed

+9
-12
lines changed

3 files changed

+9
-12
lines changed

models/asymkey/ssh_key_parse.go

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ import (
1616
"strconv"
1717
"strings"
1818

19-
"code.gitea.io/gitea/models/db"
2019
"code.gitea.io/gitea/modules/log"
2120
"code.gitea.io/gitea/modules/process"
2221
"code.gitea.io/gitea/modules/setting"
@@ -158,10 +157,6 @@ func parseKeyString(content string) (string, error) {
158157
// CheckPublicKeyString checks if the given public key string is recognized by SSH.
159158
// It returns the actual public key line on success.
160159
func CheckPublicKeyString(content string) (_ string, err error) {
161-
if setting.SSH.Disabled {
162-
return "", db.ErrSSHDisabled{}
163-
}
164-
165160
content, err = parseKeyString(content)
166161
if err != nil {
167162
return "", err

options/locale/locale_en-US.ini

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -739,6 +739,7 @@ principal_state_desc = This principal has been used in the last 7 days
739739
show_openid = Show on profile
740740
hide_openid = Hide from profile
741741
ssh_disabled = SSH Disabled
742+
ssh_signonly = Notice: SSH is disabled, these keys will only be used for verifying commit signatures
742743
ssh_externally_managed = This SSH key is externally managed for this user
743744
manage_social = Manage Associated Social Accounts
744745
social_desc = These social accounts are linked to your Gitea account. Make sure you recognize all of them as they can be used to sign in to your Gitea account.

templates/user/settings/keys_ssh.tmpl

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,9 @@
11
<h4 class="ui top attached header">
22
{{.locale.Tr "settings.manage_ssh_keys"}}
33
<div class="ui right">
4-
{{if not .DisableSSH}}
5-
<button id="add-ssh-button" class="ui primary tiny show-panel button" data-panel="#add-ssh-key-panel">
6-
{{.locale.Tr "settings.add_key"}}
7-
</button>
8-
{{else}}
9-
<button class="ui primary tiny button disabled">{{.locale.Tr "settings.ssh_disabled"}}</button>
10-
{{end}}
4+
<button id="add-ssh-button" class="ui primary tiny show-panel button" data-panel="#add-ssh-key-panel">
5+
{{.locale.Tr "settings.add_key"}}
6+
</button>
117
</div>
128
</h4>
139
<div class="ui attached segment">
@@ -35,6 +31,11 @@
3531
<div class="item">
3632
{{.locale.Tr "settings.ssh_desc"}}
3733
</div>
34+
{{if .DisableSSH}}
35+
<div class="item">
36+
{{.locale.Tr "settings.ssh_signonly"}}
37+
</div>
38+
{{end}}
3839
{{range $index, $key := .Keys}}
3940
<div class="item">
4041
<div class="right floated content">

0 commit comments

Comments
 (0)