Merge pull request #111 from shawn111/missing_authorized_key

Fix userkey create.
This commit is contained in:
Manfred Touron 2019-01-03 19:57:19 +01:00 committed by GitHub
commit f220af5c54
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 4 deletions

2
db.go
View file

@ -70,7 +70,7 @@ type Host struct {
// UserKey defines a user public key used by sshportal to identify the user
type UserKey struct {
gorm.Model
Key []byte `sql:"size:10000" valid:"required,length(1|10000)"`
Key []byte `sql:"size:10000" valid:"length(1|10000)"`
AuthorizedKey string `sql:"size:10000" valid:"required,length(1|10000)"`
UserID uint ``
User *User `gorm:"ForeignKey:UserID"`

View file

@ -16,6 +16,8 @@ import (
"github.com/mgutz/ansi"
"github.com/moby/moby/pkg/namesgenerator"
"github.com/moul/ssh"
gossh "golang.org/x/crypto/ssh"
"github.com/olekukonko/tablewriter"
"github.com/urfave/cli"
"golang.org/x/crypto/ssh/terminal"
@ -1925,9 +1927,10 @@ GLOBAL OPTIONS:
}
userkey := UserKey{
User: &user,
Key: key.Marshal(),
Comment: comment,
User: &user,
Key: key.Marshal(),
Comment: comment,
AuthorizedKey: string(gossh.MarshalAuthorizedKey(key)),
}
if c.String("comment") != "" {
userkey.Comment = c.String("comment")