Commit Graph

123 Commits

Author SHA1 Message Date
Aidan Steele
c2883aad47
Import x/net/crypto/ssh with alias gossh 2019-01-07 08:09:35 +11:00
Aidan Steele
6dcd5356b5 Added Server.KeyboardInteractiveHandler 2019-01-06 15:25:33 +11:00
Jose Diaz-Gonzalez
570aa23f40
fix: use idiomatic go 2018-12-23 18:05:39 -05:00
Manfred Touron
8b3cdd49b6
feat: configurable server handlers 2018-11-16 14:56:57 +01:00
Jeff Lindsay
cbabf54144
Remote forwarding (#88)
* context: fixed documentation to be more specific about ContextKeyConn being the key for a gossh.ServerConn

Signed-off-by: Jeff Lindsay <progrium@gmail.com>

* server: fixes handler setup, changed to interface based handlers, added global request handler map

* tcpip: working remote forwarding

Signed-off-by: Jeff Lindsay <progrium@gmail.com>

* context: docs typo

Signed-off-by: Jeff Lindsay <progrium@gmail.com>

* session: always reply to unblock clients trying something

Signed-off-by: Jeff Lindsay <progrium@gmail.com>

* tcpip: stop listening when ssh clients disconnect

Signed-off-by: Jeff Lindsay <progrium@gmail.com>

* Remote forwarding (#87)

* Update generateSigner key size to 2048 (#62)

Fixes #58

* Add syntax highlighting to readme (#67)

* small api updates (#69)

These updates make it easier to implement and pass custom Session and
Context implementations

No compatibilty breaking, all tests pass

* Move channelHandlers to avoid data race (#59)

* Update tests to work with go 1.10+ (#73)

Fixes #72

* Update shutdown to use a WaitGroup rather than sleeping (#74)

* Fix race condition in TestServerClose (#75)

In test server close, 3 things need to happen in order:

- Client session start
- Server.Close
- Client session exit (With io.EOF)

This fix ensures the client won't do anything until after the call to
close which ensure's we'll get io.EOF rather than a different error.

* Update circleci config to test multiple go versions

* Update CircleCI config to test 1.9 and the latest

The x/crypto/ssh library dropped support go < 1.9 as that's the first
version to have the math/bits library.

83c378c48d

* Wait for connections to finish when shutting down

PR #74 introduced a WaitGroup for listeners, but it doesn't wait for
open connections before closing the server. This patch waits until all
conns are closed before returning from Shutdown.

*  Support port forwarding of literal IPv6 addresses (#85)

* Support port forwarding of literal IPv6 addresses

To disambiguate between colons as host:port separators and as IPv6 address separators, literal IPv6 addresses use square brackets around the address (https://en.wikipedia.org/wiki/IPv6_address#Literal_IPv6_addresses_in_network_resource_identifiers).  So host ::1, port 22 is written as [::1]:22, and therefore a simple concatenation of host, colon, and port doesn't work.  Fortunately net.JoinHostPort already implements this functionality, so with a bit of type gymnastics we can generate dest in an IPv6-safe way.

* Support port forwarding of literal IPv6 addresses

To disambiguate between colons as host:port separators and as IPv6 address separators, literal IPv6 addresses use square brackets around the address (https://en.wikipedia.org/wiki/IPv6_address#Literal_IPv6_addresses_in_network_resource_identifiers).  So host ::1, port 22 is written as [::1]:22, and therefore a simple concatenation of host, colon, and port doesn't work.  Fortunately net.JoinHostPort already implements this functionality, so with a bit of type gymnastics we can generate dest in an IPv6-safe way.

* Reverse port forwarding callback added

* garbage removed
2018-11-13 10:04:02 -06:00
Marc Fielding
c072a10770 Support port forwarding of literal IPv6 addresses (#85)
* Support port forwarding of literal IPv6 addresses

To disambiguate between colons as host:port separators and as IPv6 address separators, literal IPv6 addresses use square brackets around the address (https://en.wikipedia.org/wiki/IPv6_address#Literal_IPv6_addresses_in_network_resource_identifiers).  So host ::1, port 22 is written as [::1]:22, and therefore a simple concatenation of host, colon, and port doesn't work.  Fortunately net.JoinHostPort already implements this functionality, so with a bit of type gymnastics we can generate dest in an IPv6-safe way.

* Support port forwarding of literal IPv6 addresses

To disambiguate between colons as host:port separators and as IPv6 address separators, literal IPv6 addresses use square brackets around the address (https://en.wikipedia.org/wiki/IPv6_address#Literal_IPv6_addresses_in_network_resource_identifiers).  So host ::1, port 22 is written as [::1]:22, and therefore a simple concatenation of host, colon, and port doesn't work.  Fortunately net.JoinHostPort already implements this functionality, so with a bit of type gymnastics we can generate dest in an IPv6-safe way.
2018-09-23 19:41:38 -05:00
John Barnette
d3a6756290 Wait for connections to finish when shutting down
PR #74 introduced a WaitGroup for listeners, but it doesn't wait for
open connections before closing the server. This patch waits until all
conns are closed before returning from Shutdown.
2018-05-07 16:10:55 -07:00
Kaleb Elwert
2a96aa1cdd Update CircleCI config to test 1.9 and the latest
The x/crypto/ssh library dropped support go < 1.9 as that's the first
version to have the math/bits library.

83c378c48d
2018-05-07 16:08:31 -07:00
Kaleb Elwert
8c1707734e Update circleci config to test multiple go versions 2018-04-16 19:53:05 -07:00
Kaleb Elwert
8ba78c2f83 Fix race condition in TestServerClose (#75)
In test server close, 3 things need to happen in order:

- Client session start
- Server.Close
- Client session exit (With io.EOF)

This fix ensures the client won't do anything until after the call to
close which ensure's we'll get io.EOF rather than a different error.
2018-04-16 20:00:03 -05:00
Kaleb Elwert
ef66069ab6 Update shutdown to use a WaitGroup rather than sleeping (#74) 2018-04-16 19:30:27 -05:00
Kaleb Elwert
66f55c879c Update tests to work with go 1.10+ (#73)
Fixes #72
2018-04-16 19:16:34 -05:00
phil-halley
d6295a6cbc Move channelHandlers to avoid data race (#59) 2018-04-04 13:06:36 -05:00
Manfred Touron
47df570d18 small api updates (#69)
These updates make it easier to implement and pass custom Session and
Context implementations

No compatibilty breaking, all tests pass
2018-01-09 12:15:16 -06:00
Fredrik Forsmo
ce31f3cc47 Add syntax highlighting to readme (#67) 2017-12-06 14:46:25 -06:00
Kaleb Elwert
3d95f1a04b Update generateSigner key size to 2048 (#62)
Fixes #58
2017-11-12 18:38:17 -06:00
Kaleb Elwert
0c9c3575f4 Switch to using gossh.ParsePrivateKey when reading PrivateKeys (#61)
Refs #56
2017-11-01 18:11:58 -05:00
Jeff Lindsay
3eeacb7850
session: adding signal handling support (#44) 2017-11-01 18:03:54 -05:00
Steven Murr
4a4de396c4 Merge pull request #54 from stevemurr/master
Updated SSH docker example
2017-09-01 09:20:11 -07:00
Steven Murr
2d7ad48994 updated with riku's code 2017-09-01 09:07:24 -07:00
Steven Murr
6bdaa811d6 Updated function signature in ssh-docker example. Added Dockerfile for example. Added readme for ssh-docker example. 2017-08-26 14:28:21 -07:00
Anmol Sethi
c986e7ff5f fix timeout bug (#52)
Closes #51
2017-08-11 16:45:54 -05:00
Shuanglei Tao
9ccc7bbb64 Document session context canceling (#50) 2017-07-31 13:53:11 -05:00
Jeff Lindsay
cff9b0cc85 Update README.md 2017-07-26 14:15:23 -05:00
Jeff Lindsay
7d5e696692 bump quote 2017-07-26 14:14:12 -05:00
Jeff Lindsay
aa0cea23bb ci badge 2017-07-26 14:12:57 -05:00
Jeff Lindsay
de939e7327 email updates badge 2017-07-26 13:46:22 -05:00
Jeff Lindsay
48c9603bfc server: timeouts and context canceling on closed connections (#46)
Signed-off-by: Jeff Lindsay <progrium@gmail.com>
2017-07-24 16:25:45 -05:00
Mester
f892d8d851 Added LocalAddr() to session interface (#48) 2017-07-20 17:09:24 -05:00
Jeff Lindsay
33ad2fe318 [proposal] ConnCallback (#36)
ConnCallback lets you wrap connection objects for timeouts and limiting
2017-07-12 12:27:56 -05:00
Jeff Lindsay
bf3073636e server: fixing change in test helper api (#42)
Signed-off-by: Jeff Lindsay <progrium@gmail.com>
2017-05-23 17:42:30 -05:00
aerth
74da58b7bb check for nil interface before returning public key (#37) 2017-05-22 16:12:18 -05:00
Matt Aitchison
b47c6daa4b server: first pass at Shutdown and Close (#34)
* server: first pass at Shutdown and Close
* server: remove unused struct field
* server: replace http reference in error

closes: #22
2017-05-22 16:11:06 -05:00
Mahmood Ali
bbb28830b0 update config for CircleCI 2.0 (#39) 2017-04-29 00:11:02 -05:00
Mahmood Ali
20a454724d Support for local port forwarding (#38)
* Support local port forwarding
* refactor testSession to return ssh client as well
* Tests for local port forwarding
2017-04-28 17:54:12 -05:00
Jeff Lindsay
1051a0d154 agent forwarding support (#31)
* agent: added agent forwarding support with an example
* context: encode session id to hex string
* agent: ensure conn doesn't change in closure as loop iterates
* tests: use HostKeyCallback in ClientConfig
* README: noting examples in _example
* agent: documented exported names, added constants for temp file creation

Signed-off-by: Jeff Lindsay <progrium@gmail.com>
2017-04-14 14:47:40 -05:00
Jeff Lindsay
9b56478e13 contexts (#29)
* context: working mostly tested context implementation and refactoring to go with it
* _example/ssh-publickey: updating new context based callbacks
* godocs related to public api changes for contexts
* context: converting []bytes to strings before putting into context

Signed-off-by: Jeff Lindsay <progrium@gmail.com>
2017-03-14 14:13:03 -05:00
Pia Mancini
791cd4b75f Add backers and sponsors from Open Collective (#30)
Now your open collective backers and sponsors can to appear directly on your README. 
see how it'll look [here](https://github.com/apex/apex#backers)
[More info](https://github.com/opencollective/opencollective/wiki/Github-banner)
Also add badges on top.
2017-03-06 14:25:59 -06:00
Jeff Lindsay
6f812536df Update README.md 2017-03-03 16:14:44 -06:00
Jeff Lindsay
edf30fc0aa Fix short write (#28)
* session: pty normalization hack needs to return expected bytes written or chaos ensues, such as short write errors
* _example: renaming to avoid editors that auto-install from making docker binaries in your path that aren't docker
* session: keep extra calculations limited to pty case

Signed-off-by: Jeff Lindsay <progrium@gmail.com>
2017-02-16 15:59:07 -06:00
Jeff Lindsay
a2a474964c fixed/finished basic pty support, added an example, and included tests (#25)
* fixed/finished basic pty support, added an example, and included tests
* session: make the window channel have buffer of 1 and send initial window size on it
* _example/docker: added an ssh to docker-run example
* changes from review: let Reply handle WantReply, only allow setting sess.pty once
* circle: hopefully a working circleci config
2017-02-15 18:08:25 -06:00
Jeff Lindsay
a307f226ad Merge pull request #24 from gliderlabs/misc-progrium
fixing a type led to general example cleanup. also added a helpful comment.
2017-02-15 09:19:46 -06:00
Jeff Lindsay
0922cadde6 fixing a type led to general cleanup. also added a comment.
Signed-off-by: Jeff Lindsay <progrium@gmail.com>
2017-02-14 18:30:43 -06:00
Jeff Lindsay
f3131153bc Merge pull request #21 from hloeffler/master
output port
2017-02-04 16:51:04 -06:00
hloeffler
398834c640 output port 2017-02-04 22:45:40 +01:00
Jeff Lindsay
39bc88bc6d Merge pull request #15 from atlassian/belak/always-send-pty-response
Always respond to PTY requests
2017-02-03 18:42:23 -06:00
Jeff Lindsay
3c20372393 Merge pull request #19 from atlassian/belak/add-server-version
Add ServerVersion as an option in the config
2017-02-03 18:25:05 -06:00
Kaleb Elwert
80be538d5c Add ServerVersion as an option in the config 2017-02-03 16:22:13 -08:00
Jeff Lindsay
d6ddd5d5dc Merge pull request #18 from atlassian/belak/ensure-exit-only-called-once
Ensure Session.Exit can only be called once
2017-02-03 18:19:25 -06:00
Kaleb Elwert
71d4b985d1 Ensure Session.Exit can only be called once 2017-02-03 16:00:28 -08:00