Skip to content

Instantly share code, notes, and snippets.

@HwDhyeon
Created March 6, 2020 05:14
Show Gist options
  • Save HwDhyeon/3a0092f2a915612fad7e3950edac7844 to your computer and use it in GitHub Desktop.
Save HwDhyeon/3a0092f2a915612fad7e3950edac7844 to your computer and use it in GitHub Desktop.
ssh 모듈을 이용해 ssh 서버 생성하기
package main
import (
"time"
"github.com/gliderlabs/ssh"
)
func main() {
MaxTimeout := time.Second * 20
IdleTimeout := time.Second * 10
ssh.Handle(func(s ssh.Session) {
i := 0
for {
i++
select {
case <-time.After(time.Second):
continue
case <-s.Context().Done():
return
}
}
})
server := &ssh.Server{
Addr: ":22",
MaxTimeout: MaxTimeout,
IdleTimeout: IdleTimeout,
}
err := server.ListenAndServe()
if err != nil {
panic(err)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment