summaryrefslogtreecommitdiffhomepage
path: root/tempfork/gliderlabs/ssh/example_test.go
diff options
context:
space:
mode:
authorNick Khyl <nickk@tailscale.com>2024-12-05 13:16:48 -0600
committerNick Khyl <nickk@tailscale.com>2024-12-05 13:16:48 -0600
commit0267fe83b200f1702a2fa0a395442c02a053fadb (patch)
tree63654c55225eeb834de59a5a0bc8d19033c6145b /tempfork/gliderlabs/ssh/example_test.go
parent87546a5edf6b6503a87eeb2d666baba57398a066 (diff)
downloadtailscale-1.78.0.tar.xz
tailscale-1.78.0.zip
VERSION.txt: this is v1.78.0v1.78.0
Signed-off-by: Nick Khyl <nickk@tailscale.com>
Diffstat (limited to 'tempfork/gliderlabs/ssh/example_test.go')
-rw-r--r--tempfork/gliderlabs/ssh/example_test.go100
1 files changed, 50 insertions, 50 deletions
diff --git a/tempfork/gliderlabs/ssh/example_test.go b/tempfork/gliderlabs/ssh/example_test.go
index c174bc4ae..61ffebbc0 100644
--- a/tempfork/gliderlabs/ssh/example_test.go
+++ b/tempfork/gliderlabs/ssh/example_test.go
@@ -1,50 +1,50 @@
-package ssh_test
-
-import (
- "errors"
- "io"
- "os"
-
- "tailscale.com/tempfork/gliderlabs/ssh"
-)
-
-func ExampleListenAndServe() {
- ssh.ListenAndServe(":2222", func(s ssh.Session) {
- io.WriteString(s, "Hello world\n")
- })
-}
-
-func ExamplePasswordAuth() {
- ssh.ListenAndServe(":2222", nil,
- ssh.PasswordAuth(func(ctx ssh.Context, pass string) bool {
- return pass == "secret"
- }),
- )
-}
-
-func ExampleNoPty() {
- ssh.ListenAndServe(":2222", nil, ssh.NoPty())
-}
-
-func ExamplePublicKeyAuth() {
- ssh.ListenAndServe(":2222", nil,
- ssh.PublicKeyAuth(func(ctx ssh.Context, key ssh.PublicKey) error {
- data, err := os.ReadFile("/path/to/allowed/key.pub")
- if err != nil {
- return err
- }
- allowed, _, _, _, err := ssh.ParseAuthorizedKey(data)
- if err != nil {
- return err
- }
- if !ssh.KeysEqual(key, allowed) {
- return errors.New("some error")
- }
- return nil
- }),
- )
-}
-
-func ExampleHostKeyFile() {
- ssh.ListenAndServe(":2222", nil, ssh.HostKeyFile("/path/to/host/key"))
-}
+package ssh_test
+
+import (
+ "errors"
+ "io"
+ "os"
+
+ "tailscale.com/tempfork/gliderlabs/ssh"
+)
+
+func ExampleListenAndServe() {
+ ssh.ListenAndServe(":2222", func(s ssh.Session) {
+ io.WriteString(s, "Hello world\n")
+ })
+}
+
+func ExamplePasswordAuth() {
+ ssh.ListenAndServe(":2222", nil,
+ ssh.PasswordAuth(func(ctx ssh.Context, pass string) bool {
+ return pass == "secret"
+ }),
+ )
+}
+
+func ExampleNoPty() {
+ ssh.ListenAndServe(":2222", nil, ssh.NoPty())
+}
+
+func ExamplePublicKeyAuth() {
+ ssh.ListenAndServe(":2222", nil,
+ ssh.PublicKeyAuth(func(ctx ssh.Context, key ssh.PublicKey) error {
+ data, err := os.ReadFile("/path/to/allowed/key.pub")
+ if err != nil {
+ return err
+ }
+ allowed, _, _, _, err := ssh.ParseAuthorizedKey(data)
+ if err != nil {
+ return err
+ }
+ if !ssh.KeysEqual(key, allowed) {
+ return errors.New("some error")
+ }
+ return nil
+ }),
+ )
+}
+
+func ExampleHostKeyFile() {
+ ssh.ListenAndServe(":2222", nil, ssh.HostKeyFile("/path/to/host/key"))
+}