Skip to content

Instantly share code, notes, and snippets.

Created August 3, 2022 01:39
What would you like to do?
package main
import (
func main() {
config := ssh.ClientConfig{
User: "root",
Auth: []ssh.AuthMethod{
HostKeyCallback: ssh.InsecureIgnoreHostKey(),
client, _ := ssh.Dial("tcp", "localhost:2222", &config)
defer client.Close()
sess, _ := client.NewSession()
defer sess.Close()
var buff bytes.Buffer
sess.Stdout = &buff
sess.Run("uname -a")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment