diff --git a/misc/ssh/rsa.go b/misc/ssh/rsa.go index cb0ea640..0b724fba 100644 --- a/misc/ssh/rsa.go +++ b/misc/ssh/rsa.go @@ -31,10 +31,16 @@ func init() { ) aaa.Index.MergeCommands(ice.Commands{ RSA: {Name: "rsa hash auto", Help: "密钥", Actions: ice.MergeActions(ice.Actions{ + mdb.INPUTS: {Hand: func(m *ice.Message, arg ...string) { + switch arg[0] { + case TITLE: + m.Push(arg[0], kit.Format("%s@%s", m.Option(ice.MSG_USERNAME), ice.Info.Hostname)) + } + }}, mdb.CREATE: {Name: "create bits=2048,4096 title=some", Hand: func(m *ice.Message, arg ...string) { if key, err := rsa.GenerateKey(rand.Reader, kit.Int(m.Option(BITS))); !m.Warn(err, ice.ErrNotValid) { if pub, err := ssh.NewPublicKey(key.Public()); !m.Warn(err, ice.ErrNotValid) { - mdb.HashCreate(m, m.OptionSimple(TITLE), PUBLIC, string(ssh.MarshalAuthorizedKey(pub)), + mdb.HashCreate(m, m.OptionSimple(TITLE), PUBLIC, string(ssh.MarshalAuthorizedKey(pub))+ice.SP+m.Option(TITLE), PRIVATE, string(pem.EncodeToMemory(&pem.Block{Type: "RSA PRIVATE KEY", Bytes: x509.MarshalPKCS1PrivateKey(key)})), ) }