support host key for dabases
This commit is contained in:
parent
c0ae381d48
commit
3e597d6f04
1 changed files with 13 additions and 1 deletions
|
|
@ -27,6 +27,18 @@ func (p *plugin) findUpstream(conn ssh.ConnMetadata) (net.Conn, *ssh.AuthPipe, e
|
|||
return nil, nil, err
|
||||
}
|
||||
|
||||
hostKeyCallback := ssh.InsecureIgnoreHostKey()
|
||||
|
||||
if !d.Upstream.Server.IgnoreHostKey {
|
||||
|
||||
key, err := ssh.ParsePublicKey([]byte(d.Upstream.Server.HostKey.Key.Data))
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
|
||||
hostKeyCallback = ssh.FixedHostKey(key)
|
||||
}
|
||||
|
||||
pipe := ssh.AuthPipe{
|
||||
User: d.Upstream.Username,
|
||||
|
||||
|
|
@ -56,7 +68,7 @@ func (p *plugin) findUpstream(conn ssh.ConnMetadata) (net.Conn, *ssh.AuthPipe, e
|
|||
return ssh.AuthPipeTypeNone, nil, nil
|
||||
},
|
||||
|
||||
UpstreamHostKeyCallback: ssh.InsecureIgnoreHostKey(),
|
||||
UpstreamHostKeyCallback: hostKeyCallback,
|
||||
}
|
||||
return c, &pipe, nil
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue