2019-08-13 09:48:47 -05:00
|
|
|
package main
|
|
|
|
|
2019-08-13 10:43:40 -05:00
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
|
|
|
|
"golang.org/x/crypto/ssh"
|
|
|
|
)
|
|
|
|
|
|
|
|
type SSHConnection struct {
|
2019-08-13 10:10:18 -05:00
|
|
|
Username string
|
|
|
|
Password string
|
|
|
|
Port string
|
|
|
|
Hosts []string
|
2019-08-13 09:48:47 -05:00
|
|
|
}
|
2019-08-13 10:43:40 -05:00
|
|
|
|
|
|
|
func initializeConnection(config Configuration) (SSHConnection, *ssh.ClientConfig) {
|
|
|
|
var sshConn SSHConnection
|
|
|
|
sshConn.Username = config.Username
|
|
|
|
sshConn.Password = config.Password
|
|
|
|
sshConn.Port = config.Port
|
|
|
|
sshConn.Hosts = config.Hosts
|
|
|
|
|
|
|
|
sshConfig := &ssh.ClientConfig{
|
|
|
|
User: sshConn.Username,
|
|
|
|
Auth: []ssh.AuthMethod{
|
|
|
|
ssh.Password(sshConn.Password),
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
return sshConn, sshConfig
|
|
|
|
}
|
|
|
|
|
|
|
|
func (sshConn SSHConnection) DialConnection(sshConnec *ssh.ClientConfig) {
|
|
|
|
for _, j := range sshConn.Hosts {
|
|
|
|
fmt.Println(j)
|
|
|
|
}
|
|
|
|
}
|