-
-
Notifications
You must be signed in to change notification settings - Fork 14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Check] -distribute flag with ssh targets #34
Comments
Memossh client
package main
import (
"fmt"
"log"
"os"
"golang.org/x/crypto/ssh"
)
func main() {
if len(os.Args) != 4 {
log.Fatalf("Usage: %s <user> <host:port> <command>", os.Args[0])
}
client, session, err := connectToHost(os.Args[1], os.Args[2])
if err != nil {
panic(err)
}
out, err := session.CombinedOutput(os.Args[3])
if err != nil {
panic(err)
}
fmt.Println(string(out))
client.Close()
}
func connectToHost(user, host string) (*ssh.Client, *ssh.Session, error) {
var pass string
fmt.Print("Password: ")
fmt.Scanf("%s\n", &pass)
sshConfig := &ssh.ClientConfig{
User: user,
Auth: []ssh.AuthMethod{ssh.Password(pass)},
}
sshConfig.HostKeyCallback = ssh.InsecureIgnoreHostKey()
client, err := ssh.Dial("tcp", host, sshConfig)
if err != nil {
return nil, nil, err
}
session, err := client.NewSession()
if err != nil {
client.Close()
return nil, nil, err
}
return client, session, nil
}
ssh client (password / public key)https://gist.github.com/HwDhyeon/4250215d5166bc0244df8978af2e7e71 |
type AuthMethod type Session |
or go-scp |
SSIA
The text was updated successfully, but these errors were encountered: