프로젝트
GitHub에서 보기
yahoo/vssh
소개
SSH를 통해 대규모로 명령을 실행하는 Go 라이브러리
시스템 및 인프라What you can do
- Connect to multiple remote machines concurrently
- Persistent SSH connection
- DSL query based on the labels
- Manage number of sessions per SSH connection
측정된 스타 증가
- in 24h
- 0
- in 7 days
- 0
- in 15 days
- -1
- in 1 month
- 기록 수집 중
서로 겹치는 기간의 순증가량이며 일별 합계가 아닙니다. 측정값이 없으면 비워 둡니다. 스타는 관심도를 나타내며 품질을 보장하지 않습니다.
README.md
OriginalvSSH
Go library to handle tens of thousands SSH connections and execute the command(s) with higher-level API for building network device / server automation. Documentation and examples are available via godoc.

Features
- Connect to multiple remote machines concurrently
- Persistent SSH connection
- DSL query based on the labels
- Manage number of sessions per SSH connection
- Limit amount of stdout and stderr data in bytes
- Higher-level API for building automation
Sample query with label
labels := map[string]string {
"POP" : "LAX",
"OS" : "JUNOS",
}
// sets labels to a client
vs.AddClient(addr, config, vssh.SetLabels(labels))
// query with label
vs.RunWithLabel(ctx, cmd, timeout, "(POP == LAX || POP == DCA) && OS == JUNOS")
Basic example
vs := vssh.New().Start()
config := vssh.GetConfigUserPass("vssh", "vssh")
for _, addr := range []string{"54.193.17.197:22", "192.168.2.19:22"} {
vs.AddClient(addr, config, vssh.SetMaxSessions(4))
}
vs.Wait()
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
cmd:= "ping -c 4 192.168.55.10"
timeout, _ := time.ParseDuration("6s")
respChan := vs.Run(ctx, cmd, timeout)
for resp := range respChan {
if err := resp.Err(); err != nil {
log.Println(err)
continue
}
outTxt, errTxt, _ := resp.GetText(vs)
fmt.Println(outTxt, errTxt, resp.ExitStatus())
}
Stream example
vs := vssh.New().Start()
config, _ := vssh.GetConfigPEM("vssh", "mypem.pem")
vs.AddClient("54.193.17.197:22", config, vssh.SetMaxSessions(4))
vs.Wait()
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
cmd:= "ping -c 4 192.168.55.10"
timeout, _ := time.ParseDuration("6s")
respChan := vs.Run(ctx, cmd, timeout)
resp := <- respChan
if err := resp.Err(); err != nil {
log.Fatal(err)
}
stream := resp.GetStream()
defer stream.Close()
for stream.ScanStdout() {
txt := stream.TextStdout()
fmt.Println(txt)
}
Supported platform
- Linux
- Windows
- Darwin
- BSD
- Solaris
License
Code is licensed under the Apache License, Version 2.0 (the "License"). Content is licensed under the CC BY 4.0 license. Terms available at https://creativecommons.org/licenses/by/4.0/.
Contribute
Welcomes any kind of contribution, please follow the next steps:
- Fork the project on github.com.
- Create a new branch.
- Commit changes to the new branch.
- Send a pull request.
관련 프로젝트 살펴보기
불러오는 중…