Commit Graph
159 Commits
Author SHA1 Message Date
Han-Wen Nienhuys 88b65fb663 ssh: return session ID in ConnMeta.SessionID.
SessionID() returned nil previously.

Fixes #9761.

Change-Id: I53d2b347571d21eab2d913c2228e85997a84f757
Reviewed-on: https://go-review.googlesource.com/3872
Reviewed-by: Adam Langley <agl@golang.org>
2015-02-04 17:27:33 +00:00
Dave Cheney 7db43667c7 ssh: make godoc examples easier to reuse
Fixes golang/go#9747

Move the example tests to an external test package so that they
must explicitly reference the ssh package. The side effect is the
examples now become easier to copy and paste.

Change-Id: Ibbddea42bc5a41d11ffdef5144d9884ef3ef603f
Reviewed-on: https://go-review.googlesource.com/3710
Reviewed-by: Andrew Gerrand <adg@golang.org>
2015-02-02 06:42:08 +00:00
Michael Marineau 160b2e156e ssh/agent: do not return nil entries from keyring.Signers()
The slice returned is constructed with both a pre-set length and
append() resulting in a slice twice as long and half-full of nil.
Setting the capacity instead of length gets the desired result.

Change-Id: I758423594e4f4c0506c53f227454f57a9dc8bdf1
Reviewed-on: https://go-review.googlesource.com/2659
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-01-12 20:38:54 +00:00
Kristopher Watts 280be005b3 ssh: add ServerConfig.ServerVersion option
The SSH server does not allow for setting a version string in the same
manner as the client.  This update adds a ServerVersion member to the
ServerConfig structure which when set, causes the server to use that
member instead of the default version string.  This allows building
an golang based SSH server which can present any version string
the user wishes.

It also adds an else statement to the client assignment of the
ClientVersion to avoid an allocation when using a user defined
ClientVersion.

Change-Id: I43d97cfd5a174f2c68f53c5b4e267539ef21937b
Reviewed-on: https://go-review.googlesource.com/1860
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-01-06 03:05:11 +00:00
Derek Che a7ead6ddf0 ssh/terminal: fix SetSize when nothing on current line
SetSize has a problem may cause the following ReadPassword setting
temporary prompt not working, when changing width the current
SetSize will call clearAndRepaintLinePlusNPrevious which would
print an old prompt whatever the current line has, causing a following
ReadPassword with temporary prompt not printing the different prompt.

When running code like this, the nt.SetSize prints a "> " as
prompt then the temporary "Password: " prompt would never show up.

```go
        oldState, err := terminal.MakeRaw(int(os.Stdin.Fd()))
        width, height, _ = terminal.GetSize(int(os.Stdin.Fd()))
        nt := terminal.NewTerminal(os.Stdin, "> ")
        nt.SetSize(width, height)
        password, err = nt.ReadPassword("Password: ")
```

the new test cases is to test SetSize with different terminal sizes,
either shrinking or expanding, a following ReadPassword should get the
correct temporary prompt.

Change-Id: I33d13b2c732997c0c88670d53545b8c0048b94b6
Reviewed-on: https://go-review.googlesource.com/1861
Reviewed-by: Adam Langley <agl@golang.org>
2014-12-19 22:48:49 +00:00
David Symonds 1fbbd62cfe crypto: add import comments.
Change-Id: I33240faf1b8620d0cd600de661928d8e422ebdbc
Reviewed-on: https://go-review.googlesource.com/1235
Reviewed-by: Andrew Gerrand <adg@golang.org>
2014-12-09 23:26:36 +00:00
Adam Langley 5ff91abc76 go.crypto/ssh/terminal: support bracketed paste mode.
Some terminals support a mode where pasted text is bracketed by escape sequences. This is very useful for terminal applications that otherwise have no good way to tell pastes and typed text apart.

This change allows applications to enable this mode and, if the terminal supports it, will suppress autocompletes during pastes and indicate to the caller that a line came entirely from pasted text.

LGTM=bradfitz
R=bradfitz
CC=golang-codereviews
https://golang.org/cl/171330043
2014-11-16 14:01:45 -08:00
Andrew Gerrand a73c6bbfc5 go.crypto: use golang.org/x/... import paths
LGTM=bradfitz
R=rsc, bradfitz
CC=golang-codereviews
https://golang.org/cl/167190043
2014-11-10 08:50:25 +11:00
Adam Langley 1a85842c9e go.crypto/ssh/terminal: fix Home and End.
In my notes I had Home and End down as OH and OF. But that's nonsense, they are [H and ]F.
I never noticed before because I don't have Home and End keys on my keyboard.

LGTM=bradfitz
R=bradfitz
CC=golang-codereviews
https://golang.org/cl/172100043
2014-11-07 19:20:14 -08:00
Adam Langley 30ad74476e go.crypto/ssh/terminal: remove \r from passwords on Windows.
Fixes golang/go#9040.

(Note: can't compile or test this one prior to committing.)

LGTM=iant, bradfitz
R=bradfitz, mathias.gumz, iant
CC=golang-codereviews
https://golang.org/cl/171000043
2014-11-04 10:58:06 -08:00
Adam Langley 7780ec1765 go.crypto/ssh/terminal: fix crash when terminal narrower than prompt.
Previously, if the current line was "empty", resizes wouldn't trigger
repaints. However, the line can be empty when the prompt is non-empty
and the code would then panic after a resize because the cursor position
was outside of the terminal.

LGTM=bradfitz
R=bradfitz
CC=golang-codereviews
https://golang.org/cl/158090043
2014-10-25 11:16:08 -07:00
Han-Wen Nienhuys 72116d5c17 go.crypto/ssh: clean up address parsing in forward code.
LGTM=agl
R=agl, dave, jpsugar
CC=golang-codereviews
https://golang.org/cl/134700043
2014-09-16 12:34:31 -07:00
Han-Wen Nienhuys fc84ae5437 go.crypto/ssh: reuse packet buffer for channel writes.
Test that different extended data streams within a channel are
thread-safe.

benchmark             old MB/s     new MB/s     speedup
BenchmarkEndToEnd     79.26        87.98        1.11x

benchmark                          old allocs     new allocs     delta
BenchmarkEndToEnd                  110            73             -33.64%

benchmark                          old bytes     new bytes     delta
BenchmarkEndToEnd                  2605720       1299768       -50.12%

LGTM=dave, jpsugar
R=agl, dave, jpsugar
CC=golang-codereviews
https://golang.org/cl/136420043
2014-09-16 12:30:05 -07:00
Han-Wen Nienhuys 9e886ee4f2 go.crypto/ssh: skip tests that start ssh-agent.
Also stops leaking /tmp/ directories.

Fixes golang/go#8489.

LGTM=dave, minux
R=dave, minux, agl
CC=golang-codereviews
https://golang.org/cl/124010043
2014-08-13 10:56:59 -07:00
Dave Cheney ed03dad8de go.crypto/ssh/test: skip tests during -short mode
This proposal effectively disables all the ssh/test tests when run with the -short flag supplied.

For developers and users of this package, there should be no change unless they are in the habbit of always supplying -short, which I belive is untrue.

For the CI dashboard the effect should be that these tests, which are really not portable enough to run reliably on all our various builders, are disabled.

LGTM=adg
R=adg, agl, hanwen
CC=golang-codereviews
https://golang.org/cl/125860043
2014-08-08 11:42:28 +10:00
Adam Langley 76cee1b7b1 go.crypto/ssh/terminal: better handling of window resizing.
There doesn't appear to be perfect behaviour for line editing
code in the face of terminal resizing. But this change works
pretty well on xterm and gnome-terminal and certainly a lot
better than it used to.

LGTM=bradfitz
R=bradfitz
CC=golang-codereviews
https://golang.org/cl/105580043
2014-08-01 11:22:47 -07:00
Dave Cheney 2aff5f12d8 go.crypt/ssh/terminal: declare TCGETS, TCSETS constants locally.
Currently the ssh/terminal package cannot be compiled under gccgo. Even though gccgo may be running on linux, its syscall package is slightly different and does not contain these constants.

This proposal resolves the issue by declaring the two constants locally, as we've done for the *BSDs.

LGTM=hanwen, iant
R=hanwen, iant, gobot
CC=golang-codereviews
https://golang.org/cl/101670043
2014-07-07 10:24:36 +10:00
Adam Langley 9fb3568646 go.crypto/ssh/terminal: support ^U, ^D and ^L.
LGTM=bradfitz
R=bradfitz, marios.nikolaou
CC=golang-codereviews
https://golang.org/cl/92220043
2014-05-27 19:45:07 -07:00
Adam Langley c34e38ab9e go.crypto/ssh: fix authentication after all public keys are rejected by a server.
Validating a public key doesn't return any remaining methods so, if all public keys were rejected, a nil slice would be returned for the remaining methods and authentication would stop.

We could have validateKey return methods, but that wouldn't solve the problem of what to do if the callback returns no keys. In that case we don't have any keys to test.

So this change makes it possible for an AuthMethod to return a nil slice for the remaining methods (meaning "reuse the last list"). It also fixes a scoping bug.

Fixes golang/go#7787.

LGTM=hanwen
R=hanwen
CC=golang-codereviews
https://golang.org/cl/94350043
2014-05-13 10:51:53 -07:00
Adam Langley 2dfe547928 go.crypto/ssh: use permissions from public key cache when accepting a key.
Fixes golang/go#7913.

LGTM=hanwen
R=hanwen
CC=golang-codereviews
https://golang.org/cl/96220043
2014-05-12 11:19:56 -07:00
Han-Wen Nienhuys 6f0540ef5e go.crypto/ssh: try authentication methods in ClientConfig order.
LGTM=jpsugar, agl
R=agl, jpsugar
CC=golang-codereviews
https://golang.org/cl/92240045
2014-05-12 11:16:49 -07:00
Mikio Hara f8eacb97ce go.crypto/ssh/test: enable test cases on dragonfly
LGTM=agl
R=golang-codereviews, agl
CC=golang-codereviews
https://golang.org/cl/98840043
2014-05-05 12:10:24 -07:00
Mikio Hara b71337fce2 go.crypto/ssh/terminal: add support for BSD variants
LGTM=agl
R=golang-codereviews, agl
CC=golang-codereviews
https://golang.org/cl/97850043
2014-05-05 12:07:22 -07:00
David Calavera df2851958a ssh/forward: Fix reference to the functions to call to route authentication requests.
R=agl
CC=golang-codereviews, hanwen
https://golang.org/cl/95910043
2014-05-02 10:55:29 -07:00
Han-Wen Nienhuys 7c7765c32f go.crypto/ssh/agent: add key type to testAgentInterface failure messages.
R=agl, dave, jpsugar
CC=golang-codereviews
https://golang.org/cl/88260043
2014-04-15 13:48:43 -07:00
Han-Wen Nienhuys 15264ff7c7 go.crypto/ssh/agent: prefix errors with "agent".
R=agl, dave, jpsugar
CC=golang-codereviews
https://golang.org/cl/87810047
2014-04-15 13:42:07 -07:00
Han-Wen Nienhuys dac81c328b go.crypto/ssh: fix messages_test.go on 32-bit platforms.
LGTM=dave
R=agl, dave
CC=golang-codereviews
https://golang.org/cl/88060043
2014-04-15 09:09:03 -07:00
Yan Zou e1b0d6c49f go.crypto/ssh: Add support for the pre-2006 RC4 cipher mode.
LGTM=hanwen
R=agl, hanwen
CC=golang-codereviews
https://golang.org/cl/86600044
2014-04-14 10:43:20 -07:00
Han-Wen Nienhuys 058f0eec52 go.crypto/ssh: only offset channel IDs when debugMux is
set.

Otherwise, the package leaks data about total number of
connections established through its channel IDs.

R=agl, jpsugar
CC=golang-codereviews
https://golang.org/cl/87280043
2014-04-14 09:23:18 -07:00
David du Colombier 7e43632730 go.crypto/ssh: build test_unix_test on Plan 9
LGTM=minux.ma
R=golang-codereviews, minux.ma
CC=golang-codereviews
https://golang.org/cl/86630043
2014-04-12 22:07:48 +02:00
Adam Langley 43c4f8a896 go.crypto/ssh: remove old files.
In c0fc595a2cb5, hg didn't notice the files that had been removed from
the working directory. These, old files are breaking the build.

CC=golang-codereviews
https://golang.org/cl/86240043
2014-04-09 14:37:07 -07:00
Adam Langley fa50e7408b go.crypto/ssh: import gosshnew.
See https://groups.google.com/d/msg/Golang-nuts/AoVxQ4bB5XQ/i8kpMxdbVlEJ

R=hanwen
CC=golang-codereviews
https://golang.org/cl/86190043
2014-04-09 13:57:52 -07:00
David du Colombier a2c10b4975 go.crypto/ssh: build tests on Plan 9
LGTM=minux.ma
R=golang-codereviews, minux.ma
CC=golang-codereviews
https://golang.org/cl/64390044
2014-02-19 20:51:49 +01:00
Brad Fitzpatrick 63a71ca82d undo CL 51690043 / abf8f8812575
Breaks FreeBSD build of subrepo for non-tip users.

««« original CL description
go.crypto/ssh/terminal: enable freebsd build

syscall.Termios, which was the only thing breaking the build, is
available in go tip now
(https://code.google.com/p/go/source/detail?r=873d664b00ec)

R=golang-codereviews, bradfitz
CC=golang-codereviews
https://golang.org/cl/51690043

»»»

R=golang-codereviews, dave
CC=golang-codereviews
https://golang.org/cl/51100044
2014-01-13 15:00:50 -08:00
Michael Gehring ef64186525 go.crypto/ssh/terminal: enable freebsd build
syscall.Termios, which was the only thing breaking the build, is
available in go tip now
(https://code.google.com/p/go/source/detail?r=873d664b00ec)

R=golang-codereviews, bradfitz
CC=golang-codereviews
https://golang.org/cl/51690043
2014-01-13 14:35:19 -08:00
Jakob Borg 4758fe8ce4 go.crypto/ssh: Increase window size.
Increase window size for channels (session and tcpip) to 64 *
max packet size (32 KB), which is the same value that OpenSSH
uses. Also breaks out the relevant harcoded constants into named
constants in channel.go.

Fixes golang/go#6675.

R=golang-dev, dave, hanwen, agl
CC=golang-dev
https://golang.org/cl/18120043
2013-11-01 04:24:39 +11:00
Han-Wen Nienhuys 577ae2abf9 go.crypto/ssh: cosmetic: unnest signing code for public key auth.
R=dave
CC=golang-dev
https://golang.org/cl/15930044
2013-10-26 03:25:59 +11:00
Han-Wen Nienhuys 34df1ce598 go.crypto/ssh: in {Server,Client}Conn, read session ID from
transport layer.

R=agl, dave
CC=golang-dev
https://golang.org/cl/15870044
2013-10-25 11:15:34 -04:00
Dave Cheney c0d640c887 go.crypto/ssh: ensure {Server,Client}Conn do not expose io.ReadWriter
Transport should not be a ReadWriter. It can only write packets, i.e. no partial reads or writes. Furthermore, you can currently do ClientConn.Write() while the connection is live, which sends raw bytes over the connection. Doing so will confuse the transports because the data is not encrypted.

As a consequence, ClientConn and ServerConn stop being a net.Conn

Finally, ensure that {Server,Client}Conn implement LocalAddr and RemoteAddr methods that previously were exposed by an embedded net.Conn field.

R=hanwen
CC=golang-dev
https://golang.org/cl/16610043
2013-10-25 06:29:58 +11:00
Han-Wen Nienhuys 105632d35b go.crypto/ssh: only close connection if it was open in TestClientUnsupportedKex.
R=dave
CC=golang-dev
https://golang.org/cl/15450046
2013-10-24 04:12:59 +11:00
Jonathan Pittman 94779a0cf1 go.crypto/ssh: Implement CertTime to properly handle the "infinite" time
value ^0, which would become negative when expressed as int64.

R=agl, dave, jpsugar, hanwen
CC=golang-dev
https://golang.org/cl/15520047
2013-10-23 12:44:23 -04:00
Dave Cheney 0b167df1b4 go.crypto/ssh: additional coverage of message unmarshaling
R=golang-dev, hanwen
CC=golang-dev
https://golang.org/cl/14767043
2013-10-23 08:45:49 +11:00
Jonathan Pittman 9112f50fcd go.crypto/ssh: Add certificate verification, step up support for authorized keys
R=agl, hanwen, jpsugar, dave
CC=golang-dev
https://golang.org/cl/14540051
2013-10-22 15:12:41 -04:00
Han-Wen Nienhuys f5f25bdad0 go.crypto/ssh: put version exchange in function
R=golang-dev, dave, jpsugar, agl
CC=golang-dev
https://golang.org/cl/14641044
2013-10-17 08:54:15 +11:00
Han-Wen Nienhuys ed40a6cc35 go.crypto/ssh: move channelForwardMsg declaration.
R=golang-dev, dave
CC=golang-dev
https://golang.org/cl/14669046
2013-10-16 14:24:28 +11:00
Han-Wen Nienhuys 49702c17cc go.crypto/ssh: (un)marshal data without type byte prefix.
This helps manipulating data in global and channel request
payloads.

R=agl, dave, jpsugar
CC=golang-dev
https://golang.org/cl/14438068
2013-10-15 16:18:32 +11:00
Han-Wen Nienhuys 4a7557f2bd go.crypto/ssh: add String method to RejectionReason.
R=agl, dave
CC=golang-dev
https://golang.org/cl/14494055
2013-10-14 16:13:09 -04:00
Han-Wen Nienhuys 7dc9a79b3e go.crypto/ssh: implement memTransport using sync.Cond.
This makes memTransport safe for use with multiple
writers/closers.

R=golang-dev, dave
CC=agl, golang-dev
https://golang.org/cl/14532048
2013-10-13 08:34:25 +11:00
Jonathan Pittman 44256fa2df go.crypto/ssh: cosmetic only spelling fixes
R=agl, hanwen
CC=dave, golang-dev, jpsugar
https://golang.org/cl/14430055
2013-10-10 11:35:15 -04:00
JP Sugarbroad 15d8abf5c4 go.crypto/ssh: fix certificate parsing/marshaling.
The change to add the PublicKey interface accidentally caused certificate handling to expect an extra copy of the private key algorithm name in the binary representation. This change adapts a suitable parsing API and adds a test to ensure that cert handling isn't easily broken in the future.

R=agl, hanwen, jmpittman
CC=golang-dev
https://golang.org/cl/13272055
2013-10-09 12:56:09 -04:00