Categorygithub.com/linpinger/ssh
repositorypackage
0.3.4
Repository: https://github.com/linpinger/ssh.git
Documentation: pkg.go.dev

# README

gliderlabs/ssh

BUG 修复

  • github.com/gliderlabs/ssh/tcpip.go
  • 114行定义的addr是ip:port的字符串,当port=0时,会成功绑定一个空闲的端口,此时port就不再是0了,当本方法被多次调用 tcpip-forward 时,下面的数组下标用的是ip:port字符串,会出现port都为0,ln会覆盖旧的
  • 解决办法是在 net.Listen成功后,取新的addr
  • 修改后的代码如下:
		addr := net.JoinHostPort(reqPayload.BindAddr, strconv.Itoa(int(reqPayload.BindPort)))
		ln, err := net.Listen("tcp", addr)
		if err != nil {
			// TODO: log listen failure
			return false, []byte{}
		} else {
			addr = ln.Addr().String()
			log.Printf("+ Bind at %s", addr)
		}

GoDoc CircleCI Go Report Card OpenCollective Slack Email Updates

The Glider Labs SSH server package is dope. —@bradfitz, Go team member

This Go package wraps the crypto/ssh package with a higher-level API for building SSH servers. The goal of the API was to make it as simple as using net/http, so the API is very similar:

 package main

 import (
     "github.com/gliderlabs/ssh"
     "io"
     "log"
 )

 func main() {
     ssh.Handle(func(s ssh.Session) {
         io.WriteString(s, "Hello world\n")
     })  

     log.Fatal(ssh.ListenAndServe(":2222", nil))
 }

This package was built by @progrium after working on nearly a dozen projects at Glider Labs using SSH and collaborating with @shazow (known for ssh-chat).

Examples

A bunch of great examples are in the _examples directory.

Usage

See GoDoc reference.

Contributing

Pull requests are welcome! However, since this project is very much about API design, please submit API changes as issues to discuss before submitting PRs.

Also, you can join our Slack to discuss as well.

Roadmap

  • Non-session channel handlers
  • Cleanup callback API
  • 1.0 release
  • High-level client?

Sponsors

Become a sponsor and get your logo on our README on Github with a link to your site. [Become a sponsor]

License

BSD