diff --git a/main.go b/main.go index 5028384..be0709c 100644 --- a/main.go +++ b/main.go @@ -10,6 +10,9 @@ func main() { config := initializeConfig("config.yaml") sshConn, sshConfig := initializeConnection(config) clientConns := sshConn.dialConnection(sshConfig) + fmt.Println(clientConns) clientSessions := sshConn.openSession(clientConns) fmt.Println(clientSessions) + success := sshConn.executeTarFile(clientSessions) + fmt.Println(success) } diff --git a/remote/main.go b/remote/main.go index e69de29..ff0da6e 100644 --- a/remote/main.go +++ b/remote/main.go @@ -0,0 +1,7 @@ +package main + +import "fmt" + +func main() { + fmt.Println("Hello from the remote side!") +} diff --git a/remote/ssh_remote.go b/remote/ssh_remote.go new file mode 100644 index 0000000..2f5c8df --- /dev/null +++ b/remote/ssh_remote.go @@ -0,0 +1,5 @@ +package main + +// this file is to ssh back to the master machine to send back the tarball +// still planning this piece out. stay tuned for more! +// handsomely, Wyatt J. Miller, the guy who doesn't know what socket is headed where diff --git a/remote/tar.go b/remote/tar.go index e69de29..06ab7d0 100644 --- a/remote/tar.go +++ b/remote/tar.go @@ -0,0 +1 @@ +package main diff --git a/ssh.go b/ssh.go index d67309d..fca447f 100644 --- a/ssh.go +++ b/ssh.go @@ -21,8 +21,15 @@ type SSHConnection struct { type SSHCleints []*ssh.Client +// TODO: I've got two slices of the same type. To take one slice out, some refactoring is needed type SSHSessions []*ssh.Session +type SSHTarFile []*ssh.Session + +type SSHPush []*ssh.Client + +type SSHSuccess []error + func initializeConnection(config Configuration) (SSHConnection, *ssh.ClientConfig) { var sshConn SSHConnection sshConn.Username = config.Username @@ -63,7 +70,6 @@ func (s SSHConnection) dialConnection(sshConfig *ssh.ClientConfig) SSHCleints { } func (s SSHConnection) openSession(client SSHCleints) SSHSessions { - // don't forget there's a return type here clientSessions := SSHSessions{} for _, j := range client { @@ -78,3 +84,21 @@ func (s SSHConnection) openSession(client SSHCleints) SSHSessions { return clientSessions } + +func (s SSHConnection) executeTarFile(execute SSHSessions) SSHSuccess { + // execute order 66 lol + success := SSHSuccess{} + + for _, j := range execute { + // this is just a placeholder, change to the actual tarring executable + err := j.Run("echo 'hello world'! > test.txt") + + if err != nil { + fmt.Errorf("Can't execute program", err) + } + + success = append(success, err) + } + + return success +}