2 Star 7 Fork 1

卧雪Sirk / gosshtool

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
common.go 1022 Bytes
一键复制 编辑 原始数据 按行查看 历史
scottkiss 提交于 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
}
Go
1
https://gitee.com/scottkiss/gosshtool.git
git@gitee.com:scottkiss/gosshtool.git
scottkiss
gosshtool
gosshtool
master

搜索帮助