Created
December 11, 2013 06:09
-
-
Save sneal/7905775 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"os" | |
"fmt" | |
"code.google.com/p/go.crypto/ssh" | |
) | |
type password string | |
func (p password) Password(user string) (string, error) { | |
return string(p), nil | |
} | |
func runCmd(client *ssh.ClientConn, cmd string) { | |
session, err := client.NewSession() | |
if err != nil { | |
panic("Failed to create session: " + err.Error()) | |
} | |
session.Stdout = os.Stdout | |
session.Stderr = os.Stderr | |
err = session.Run(cmd) | |
if err != nil { | |
fmt.Println("Failed to run: " + err.Error()) | |
} | |
session.Close() | |
} | |
func main() { | |
config := &ssh.ClientConfig{ | |
User: "vagrant", | |
Auth: []ssh.ClientAuth{ | |
ssh.ClientAuthPassword(password("vagrant")), | |
}, | |
} | |
client, err := ssh.Dial("tcp", "192.168.211.209:22", config) | |
if err != nil { | |
panic("Failed to dial: " + err.Error()) | |
} | |
runCmd(client, "cmd /c dir") // <-- comment this line out for the dism cmd to suceed, or... | |
//client, _ = ssh.Dial("tcp", "192.168.211.209:22", config) // <-- uncomment this line | |
runCmd(client, "cmd /c dism.exe /online /LogLevel:4 /enable-feature /featurename:NetFx3 /norestart") | |
fmt.Println("All done!") | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment