Skip to content
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

Add sudo #33

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Add sudo #33

wants to merge 1 commit into from

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