more work on host key checking
This commit is contained in:
parent
198d0ca4b9
commit
abec574b76
@ -60,6 +60,7 @@ func (remoteConfig *Host) ConnectToSSHHost() (*ssh.Client, error) {
|
|||||||
f, _ := os.Open(filepath.Join(os.Getenv("HOME"), ".ssh", "config"))
|
f, _ := os.Open(filepath.Join(os.Getenv("HOME"), ".ssh", "config"))
|
||||||
cfg, _ := ssh_config.Decode(f)
|
cfg, _ := ssh_config.Decode(f)
|
||||||
for _, host := range cfg.Hosts {
|
for _, host := range cfg.Hosts {
|
||||||
|
var hostKey ssh.PublicKey
|
||||||
if host.Matches(remoteConfig.Host) {
|
if host.Matches(remoteConfig.Host) {
|
||||||
var identityFile string
|
var identityFile string
|
||||||
if remoteConfig.PrivateKeyPath == "" {
|
if remoteConfig.PrivateKeyPath == "" {
|
||||||
@ -90,10 +91,10 @@ func (remoteConfig *Host) ConnectToSSHHost() (*ssh.Client, error) {
|
|||||||
port = "22"
|
port = "22"
|
||||||
}
|
}
|
||||||
remoteConfig.HostName[index] = hostName + ":" + port
|
remoteConfig.HostName[index] = hostName + ":" + port
|
||||||
|
hostKey = getHostKey(hostName)
|
||||||
println("HostName: " + remoteConfig.HostName[0])
|
println("HostName: " + remoteConfig.HostName[0])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
hostKey := getHostKey(remoteConfig.HostName[0])
|
|
||||||
|
|
||||||
privateKey, err := os.ReadFile(remoteConfig.PrivateKeyPath)
|
privateKey, err := os.ReadFile(remoteConfig.PrivateKeyPath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
Loading…
Reference in New Issue
Block a user