2 Star 6 Fork 1

卧雪Sirk / gosshtool

Create your Gitee Account
Explore and code with more than 6 million developers,Free private repositories !:)
Sign up
Clone or download
common.go 1022 Bytes
Copy Edit Web IDE Raw Blame History
scottkiss authored 2016-11-03 17:59 . support file upload
package gosshtool
import (
"golang.org/x/crypto/ssh"
"io"
"log"
)
type PtyInfo struct {
Term string
H int
W int
Modes ssh.TerminalModes
}
type ReadWriteCloser interface {
io.Reader
io.WriteCloser
}
type SSHClientConfig struct {
Host string
User string
Password string
Privatekey string
DialTimeoutSecond int
MaxDataThroughput uint64
}
func makeConfig(user string, password string, privateKey string) (config *ssh.ClientConfig) {
if password == "" && user == "" {
log.Fatal("No password or private key available")
}
config = &ssh.ClientConfig{
User: user,
Auth: []ssh.AuthMethod{
ssh.Password(password),
},
}
if privateKey != "" {
log.Println(privateKey)
signer, err := ssh.ParsePrivateKey([]byte(privateKey))
if err != nil {
log.Fatalf("ssh.ParsePrivateKey error:%v", err)
}
clientkey := ssh.PublicKeys(signer)
config = &ssh.ClientConfig{
User: user,
Auth: []ssh.AuthMethod{
clientkey,
},
}
}
return
}

Comment ( 0 )

Sign in for post a comment

Go
1
https://git.oschina.net/scottkiss/gosshtool.git
git@git.oschina.net:scottkiss/gosshtool.git
scottkiss
gosshtool
gosshtool
master

Search