Add support for authentication via ssh certificates and pub/privatekey #442

Merged
6543 merged 11 commits from 42wim/tea:sshcert into main 2022-09-14 19:00:09 +00:00
2 changed files with 7 additions and 1 deletions
Showing only changes of commit 0744ebc93f - Show all commits

View File

@ -62,7 +62,7 @@ var CmdLoginAdd = cli.Command{
&cli.StringFlag{
Name: "ssh-agent-principal",
Aliases: []string{"c"},
Usage: "Use SSH certificate with specified principal to login (needs a running ssh-agent with certificate loaded)\nIf not specified first found principal will be used",
Usage: "Use SSH certificate with specified principal to login (needs a running ssh-agent with certificate loaded)",
},
&cli.StringFlag{
Name: "ssh-agent-key",

View File

@ -49,6 +49,12 @@ func CreateLogin(name, token, user, passwd, sshKey, giteaURL, sshCertPrincipal,
return fmt.Errorf("Unable to parse URL: %s", err)
}
// check if it's a certificate the principal doesn't matter as the user
// has explicitly selected this private key
if _, err := os.Stat(sshKey + "-cert.pub"); err == nil {
sshCertPrincipal = "yes"
}
login := config.Login{
Name: name,
URL: serverURL.String(),