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

Allow adding SSH keys even if SSH server is disabled #24025

Merged
merged 4 commits into from
Apr 10, 2023
Merged
Show file tree
Hide file tree
Changes from 2 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
5 changes: 0 additions & 5 deletions models/asymkey/ssh_key_parse.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import (
"strconv"
"strings"

"code.gitea.io/gitea/models/db"
"code.gitea.io/gitea/modules/log"
"code.gitea.io/gitea/modules/process"
"code.gitea.io/gitea/modules/setting"
Expand Down Expand Up @@ -158,10 +157,6 @@ func parseKeyString(content string) (string, error) {
// CheckPublicKeyString checks if the given public key string is recognized by SSH.
// It returns the actual public key line on success.
func CheckPublicKeyString(content string) (_ string, err error) {
if setting.SSH.Disabled {
return "", db.ErrSSHDisabled{}
}

content, err = parseKeyString(content)
if err != nil {
return "", err
Expand Down
1 change: 1 addition & 0 deletions options/locale/locale_en-US.ini
Original file line number Diff line number Diff line change
Expand Up @@ -739,6 +739,7 @@ principal_state_desc = This principal has been used in the last 7 days
show_openid = Show on profile
hide_openid = Hide from profile
ssh_disabled = SSH Disabled
ssh_signonly = SSH is disabled, these keys will only be used for verifying commit signatures
dsseng marked this conversation as resolved.
Show resolved Hide resolved
ssh_externally_managed = This SSH key is externally managed for this user
manage_social = Manage Associated Social Accounts
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.
Expand Down
15 changes: 8 additions & 7 deletions templates/user/settings/keys_ssh.tmpl
Original file line number Diff line number Diff line change
@@ -1,13 +1,9 @@
<h4 class="ui top attached header">
{{.locale.Tr "settings.manage_ssh_keys"}}
<div class="ui right">
{{if not .DisableSSH}}
<button id="add-ssh-button" class="ui primary tiny show-panel button" data-panel="#add-ssh-key-panel">
{{.locale.Tr "settings.add_key"}}
</button>
{{else}}
<button class="ui primary tiny button disabled">{{.locale.Tr "settings.ssh_disabled"}}</button>
{{end}}
<button id="add-ssh-button" class="ui primary tiny show-panel button" data-panel="#add-ssh-key-panel">
{{.locale.Tr "settings.add_key"}}
</button>
</div>
</h4>
<div class="ui attached segment">
Expand Down Expand Up @@ -35,6 +31,11 @@
<div class="item">
{{.locale.Tr "settings.ssh_desc"}}
</div>
{{if .DisableSSH}}
<div class="item">
silverwind marked this conversation as resolved.
Show resolved Hide resolved
{{.locale.Tr "settings.ssh_signonly"}}
</div>
{{end}}
{{range $index, $key := .Keys}}
<div class="item">
<div class="right floated content">
Expand Down