Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/itzg/go-ssh-shell
Go module that serves SSH sessions with an interactive shell
https://github.com/itzg/go-ssh-shell
golang ssh-server
Last synced: about 1 month ago
JSON representation
Go module that serves SSH sessions with an interactive shell
- Host: GitHub
- URL: https://github.com/itzg/go-ssh-shell
- Owner: itzg
- License: mit
- Created: 2019-09-19T21:23:24.000Z (about 5 years ago)
- Default Branch: master
- Last Pushed: 2023-12-19T04:04:19.000Z (11 months ago)
- Last Synced: 2024-05-01T21:50:01.727Z (7 months ago)
- Topics: golang, ssh-server
- Language: Go
- Size: 12.7 KB
- Stars: 4
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
Go module that serves SSH sessions with an interactive shell. The interactive shell includes support for command history, which can be recalled using the up/down arrow keys.
## Adding module
```
go get -u github.com/itzg/go-ssh-shell
```## Example
```go
package mainimport (
shell "github.com/itzg/go-ssh-shell"
"log"
)type exampleHandler struct {
s shell.Shell
}func exampleHandlerFactory(s *shell.Shell) shell.Handler {
return &exampleHandler{}
}func (h *exampleHandler) HandleLine(line string) error {
log.Printf("LINE from %s: %s", h.s.InstanceName(), line)
return nil
}func (h *exampleHandler) HandleEof() error {
log.Printf("EOF from %s", h.s.InstanceName())
return nil
}func main() {
sshServer := &shell.SshServer{
Config: &shell.Config{
Bind: ":2222",
Users: map[string]shell.User{
"user": {Password: "notsecure"},
},
},
HandlerFactory: exampleHandlerFactory,
}log.Fatal(sshServer.ListenAndServe())
}
```