Skip to content

Conversation

@SmsS4
Copy link

@SmsS4 SmsS4 commented Jan 29, 2022

This pr is for this issue: #21
You can now run sudo commands like this:

package main

import (
	"fmt"
	"log"
)

func main() {
	// Start new ssh connection with private key.
	auth, err := Key("/home/smss/.ssh/id_rsa", "")
	if err != nil {
		log.Fatal(err)
	}

	client, err := New("smss", "127.0.0.1", auth)
	if err != nil {
		log.Fatal(err)
	}

	// Defer closing the network connection.
	defer client.Close()
	client.SetPass("test_pass")
	out, err := client.Run("sudo ls /")

	if err != nil {
		log.Fatal(err)
	}

	// Get your output as []byte.
	fmt.Println(string(out))
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant