aboutsummaryrefslogtreecommitdiff
path: root/ssh/example_test.go
AgeCommit message (Collapse)Author
2025-10-08all: fix some typos in commentcuishuang
Change-Id: Ia209f0a6d9b19d14e655c65d1287a1416b48c487 Reviewed-on: https://go-review.googlesource.com/c/crypto/+/707535 Reviewed-by: Carlos Amedee <carlos@golang.org> Reviewed-by: Michael Pratt <mpratt@google.com> Auto-Submit: Sean Liao <sean@liao.dev> Reviewed-by: Nicola Murino <nicola.murino@gmail.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Sean Liao <sean@liao.dev>
2025-05-15ssh: export supported algorithmsNicola Murino
Fixes golang/go#61537 Change-Id: If3478121e3ae445391e3faeceeb889d75e9e3214 Reviewed-on: https://go-review.googlesource.com/c/crypto/+/531935 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Auto-Submit: Nicola Murino <nicola.murino@gmail.com> Reviewed-by: Cherry Mui <cherryyz@google.com> Reviewed-by: Michael Knyszek <mknyszek@google.com> Reviewed-by: Filippo Valsorda <filippo@golang.org>
2024-03-18all: remove redundant words in comments and fix some typoscui fliter
Change-Id: I3078492dc020770aca630e0b362df0212bd41e32 Reviewed-on: https://go-review.googlesource.com/c/crypto/+/569156 Auto-Submit: Ian Lance Taylor <iant@google.com> Reviewed-by: David Chase <drchase@google.com> Reviewed-by: Nicola Murino <nicola.murino@gmail.com> Reviewed-by: Ian Lance Taylor <iant@google.com> Auto-Submit: Nicola Murino <nicola.murino@gmail.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2023-11-09ssh: eliminate some goroutine leaks in tests and examplesBryan C. Mills
This should fix the "Log in goroutine" panic seen in https://build.golang.org/log/e42bf69fc002113dbccfe602a6c67fd52e8f31df, as well as a few other related leaks. It also helps to verify that none of the functions under test deadlock unexpectedly. See https://go.dev/wiki/CodeReviewComments#goroutine-lifetimes. Updates golang/go#58901. Change-Id: Ica943444db381ae1accb80b101ea646e28ebf4f9 Reviewed-on: https://go-review.googlesource.com/c/crypto/+/541095 Auto-Submit: Bryan Mills <bcmills@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Nicola Murino <nicola.murino@gmail.com> Reviewed-by: Heschi Kreinick <heschi@google.com>
2023-09-20ssh: add MultiAlgorithmSignerNicola Murino
MultiAlgorithmSigner allows to restrict client-side, server-side and certificate signing algorithms. Fixes golang/go#52132 Fixes golang/go#36261 Change-Id: I295092f1bba647327aaaf294f110e9157d294159 Reviewed-on: https://go-review.googlesource.com/c/crypto/+/508398 Reviewed-by: Filippo Valsorda <filippo@golang.org> Run-TryBot: Filippo Valsorda <filippo@golang.org> Reviewed-by: Ian Lance Taylor <iant@google.com> Auto-Submit: Filippo Valsorda <filippo@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2022-09-19all: replace io/ioutil with io and os packagecui fliter
For golang/go#45557 Change-Id: I447530cc66896aef7a8d528ccb8d095b80e3cf47 GitHub-Last-Rev: 5f385ff46487ac318bd1147cdbbd26bb0ffd0426 GitHub-Pull-Request: golang/crypto#230 Reviewed-on: https://go-review.googlesource.com/c/crypto/+/430797 Auto-Submit: Ian Lance Taylor <iant@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com> Reviewed-by: Meng Zhuo <mzh@golangcn.org> Run-TryBot: Ian Lance Taylor <iant@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Cherry Mui <cherryyz@google.com>
2020-10-12crypto/ssh: add Client.Close in Dial exampleEmmanuel T Odeke
Fixes golang/go#41906 Change-Id: I2eee82160a4450f531f11d5ba7bd6ed19c019992 Reviewed-on: https://go-review.googlesource.com/c/crypto/+/261417 Run-TryBot: Emmanuel Odeke <emm.odeke@gmail.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Roland Shoemaker <roland@golang.org> Reviewed-by: Kevin Burke <kev@inburke.com> Trust: Roland Shoemaker <roland@golang.org>
2019-04-11ssh: rename ExampleHostKeyCheck to ExampleClientConfig_HostKeyCallbackHan-Wen Nienhuys
Change-Id: I6d0f3396f06871286e3d48ec5af38770663dbed2 Reviewed-on: https://go-review.googlesource.com/c/crypto/+/171678 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2017-06-19ssh: clarify intended use of Permissions.Han-Wen Nienhuys
The Permissions struct should be used to pass information from authentication callback to server application. Fixes golang/go#20094. Change-Id: I5542b657d053452327260707a24925286546bfdd Reviewed-on: https://go-review.googlesource.com/45311 Run-TryBot: Han-Wen Nienhuys <hanwen@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2017-03-30ssh: require host key checking in the ClientConfigHan-Wen Nienhuys
This change breaks existing behavior. Before, a missing ClientConfig.HostKeyCallback would cause host key checking to be disabled. In this configuration, establishing a connection to any host just works, so today, most SSH client code in the wild does not perform any host key checks. This makes it easy to perform a MITM attack: * SSH installations that use keyboard-interactive or password authentication can be attacked with MITM, thereby stealing passwords. * Clients that use public-key authentication with agent forwarding are also vulnerable: the MITM server could allow the login to succeed, and then immediately ask the agent to authenticate the login to the real server. * Clients that use public-key authentication without agent forwarding are harder to attack unnoticedly: an attacker cannot authenticate the login to the real server, so it cannot in general present a convincing server to the victim. Now, a missing HostKeyCallback will cause the handshake to fail. This change also provides InsecureIgnoreHostKey() and FixedHostKey(key) as ready made host checkers. A simplistic parser for OpenSSH's known_hosts file is given as an example. This change does not provide a full-fledged parser, as it has complexity (wildcards, revocation, hashed addresses) that will need further consideration. When introduced, the host checking feature maintained backward compatibility at the expense of security. We have decided this is not the right tradeoff for the SSH library. Fixes golang/go#19767 Change-Id: I45fc7ba9bd1ea29c31ec23f115cdbab99913e814 Reviewed-on: https://go-review.googlesource.com/38701 Run-TryBot: Han-Wen Nienhuys <hanwen@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-10-04ssh: fix height/width order in RequestPty exampleHenrik Hodne
The RequestPty function takes the size arguments in the order height, then width, instead of the more common width, then height. 80 is a very common width for a terminal, so when the example reads RequestPty(..., 80, 40, ...), it's easy to assume that the order is width-height. Switching the order should make it more obvious what is going on. Change-Id: I1d6266b1c0dcde5ee6e31a6d26d2dcaf14fec58a Reviewed-on: https://go-review.googlesource.com/18290 Run-TryBot: Russ Cox <rsc@golang.org> Reviewed-by: Russ Cox <rsc@golang.org>
2016-10-04x/crypto/ssh: public key authentication exampleEmmanuel Odeke
Fixes golang/go#13902. Adds public key authentication to the password authentication example. Change-Id: I4af0ca627fb15b617cc1ba1c6e0954b013f4d94f Reviewed-on: https://go-review.googlesource.com/29374 Reviewed-by: Han-Wen Nienhuys <hanwen@google.com> Run-TryBot: Han-Wen Nienhuys <hanwen@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-10-03ssh: Consistent error handling in examplesMike Houston
After discussion around an example SFTP implementation: https://github.com/pkg/sftp/pull/54 it has been suggested that errors should be handled using log.Fatal rather than panic, and that the actual underlying error should also be logged. In the existing SSH examples there are several different styles of error handling using both panic and log.Fatalf. This patch uses log.Fatal consistently for all of these cases. Change-Id: I2cebfae1821530dc3c5bbc46d451fe026bed582f Reviewed-on: https://go-review.googlesource.com/16736 Reviewed-by: Russ Cox <rsc@golang.org>
2016-04-21x/crypto/ssh: remove misleading comment, add exampleScott Bell
Add an example for using the PublicKeys AuthMethod. Change-Id: I3fe02bb3c9b8ccf313d72858328c8576cbf3eb06 Reviewed-on: https://go-review.googlesource.com/22250 Reviewed-by: Han-Wen Nienhuys <hanwen@google.com>
2015-02-02ssh: make godoc examples easier to reuseDave Cheney
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>
2014-11-10go.crypto: use golang.org/x/... import pathsAndrew Gerrand
LGTM=bradfitz R=rsc, bradfitz CC=golang-codereviews https://golang.org/cl/167190043
2014-04-09go.crypto/ssh: import gosshnew.Adam Langley
See https://groups.google.com/d/msg/Golang-nuts/AoVxQ4bB5XQ/i8kpMxdbVlEJ R=hanwen CC=golang-codereviews https://golang.org/cl/86190043
2013-09-19go.crypto/ssh: introduce Signer method, an abstraction ofHan-Wen Nienhuys
private keys. R=agl, jpsugar, jonathan.mark.pittman CC=golang-dev https://golang.org/cl/13338044
2012-12-10go.crypto/ssh: run gofmtAdam Langley
gofmt got better at removing trailing whitespace. R=golang-dev, rsc CC=golang-dev https://golang.org/cl/6929044
2012-10-21go.crypto/ssh: add terminal modes to ssh.RequestPty()Willem van der Schyff
R=dave, agl CC=golang-dev https://golang.org/cl/6655046
2012-04-26go.crypto/ssh: add support for remote tcpip forwardingDave Cheney
Add support for server (remote) forwarded tcpip channels. See RFC4254 Section 7.1 R=gustav.paul, jeff, agl, lieqiewang CC=golang-dev https://golang.org/cl/6038047
2012-03-30go.crypto: add exp/terminal as code.google.com/p/go.crypto/ssh/terminal.David Symonds
This removes the sole "exp/foo" import in the Go subrepos. A separate CL will remove exp/terminal from the standard Go repository. R=golang-dev, dave, r CC=golang-dev https://golang.org/cl/5966045
2012-03-27go.crypto/ssh: fix example in documentationFazlul Shahriar
R=golang-dev, dave CC=golang-dev https://golang.org/cl/5905048