mirror of
https://github.com/moul/sshportal.git
synced 2024-11-10 17:26:41 +08:00
Merge pull request #111 from shawn111/missing_authorized_key
Fix userkey create.
This commit is contained in:
commit
f220af5c54
2 changed files with 7 additions and 4 deletions
2
db.go
2
db.go
|
@ -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"`
|
||||
|
|
9
shell.go
9
shell.go
|
@ -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")
|
||||
|
|
Loading…
Reference in a new issue