Get SSH host keys message handler
All checks were successful
continuous-integration/drone/push Build is passing
continuous-integration/drone Build is passing

This commit is contained in:
Adam Štrauch 2023-04-11 22:56:15 +02:00
parent df5a390680
commit 8051310677
Signed by: cx
GPG key ID: 018304FFA8988F8D
2 changed files with 40 additions and 0 deletions

View file

@ -280,6 +280,26 @@ func (c *Container) GetDeploySSHKeys() (string, string, error) {
return "", "", nil
}
// Return host key without hostname
func (c *Container) GetHostKey() (string, error) {
driver := c.getDriver()
hostKeyRaw, err := driver.Exec(c.App.Name, []string{"ssh-keyscan ", "localhost"}, "", []string{}, true)
if err != nil {
return "", err
}
if hostKeyRaw != nil {
parts := strings.SplitN(string(*hostKeyRaw), " ", 1)
if len(parts) > 1 {
return parts[1], nil
}
}
return "", nil
}
// Append text to a file in the container
func (c *Container) AppendOfFile(filename string, text string, mode string) error {
driver := c.getDriver()

View file

@ -519,6 +519,26 @@ func (p *Processor) GenerateDeploySSHKeys() (string, string, error) {
return privateKey, pubKey, nil
}
// Return SSH host key without hostname (first part of the line)
func (p *Processor) GetHostKey() (string, error) {
err := p.waitForApp()
if err != nil {
return "", err
}
container, err := p.getContainer()
if err != nil {
return "", err
}
hostKey, err := container.GetHostKey()
if err != nil {
return "", err
}
return hostKey, nil
}
// Processes returns list of supervisord processes
func (p *Processor) Processes() ([]docker.Process, error) {
container, err := p.getContainer()