2015-06-16 20:58:54 +00:00
|
|
|
package ssh
|
|
|
|
|
|
|
|
import (
|
|
|
|
"strings"
|
|
|
|
|
|
|
|
"github.com/hashicorp/vault/logical"
|
|
|
|
"github.com/hashicorp/vault/logical/framework"
|
|
|
|
)
|
|
|
|
|
2015-07-01 13:37:11 +00:00
|
|
|
func Factory(conf *logical.BackendConfig) (logical.Backend, error) {
|
|
|
|
return Backend().Setup(conf)
|
2015-06-16 20:58:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func Backend() *framework.Backend {
|
|
|
|
var b backend
|
|
|
|
b.Backend = &framework.Backend{
|
|
|
|
Help: strings.TrimSpace(backendHelp),
|
|
|
|
|
|
|
|
PathsSpecial: &logical.Paths{
|
|
|
|
Root: []string{"config/*"},
|
|
|
|
},
|
|
|
|
|
|
|
|
Paths: []*framework.Path{
|
|
|
|
pathConfigLease(&b),
|
2015-06-24 22:13:12 +00:00
|
|
|
pathKeys(&b),
|
2015-06-16 20:58:54 +00:00
|
|
|
pathRoles(&b),
|
2015-06-24 22:13:12 +00:00
|
|
|
pathRoleCreate(&b),
|
2015-06-26 01:47:32 +00:00
|
|
|
pathLookup(&b),
|
2015-06-16 20:58:54 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
Secrets: []*framework.Secret{
|
2015-07-01 15:58:49 +00:00
|
|
|
secretSSHKey(&b),
|
2015-06-16 20:58:54 +00:00
|
|
|
},
|
|
|
|
}
|
|
|
|
return b.Backend
|
|
|
|
}
|
|
|
|
|
|
|
|
type backend struct {
|
|
|
|
*framework.Backend
|
|
|
|
}
|
|
|
|
|
|
|
|
const backendHelp = `
|
2015-06-30 20:30:13 +00:00
|
|
|
The SSH backend dynamically generates SSH private keys for remote hosts.
|
2015-07-01 15:58:49 +00:00
|
|
|
The generated key has a configurable lease set and are automatically
|
2015-06-30 20:30:13 +00:00
|
|
|
revoked at the end of the lease.
|
|
|
|
|
|
|
|
After mounting this backend, configure the lease using the 'config/lease'
|
|
|
|
endpoint. The shared SSH key belonging to any infrastructure should be
|
|
|
|
registered with the 'roles/' endpoint before dynamic keys for remote hosts
|
|
|
|
can be generated.
|
2015-06-16 20:58:54 +00:00
|
|
|
`
|