OLD | NEW |
1 // Copyright 2012 The Go Authors. All rights reserved. | 1 // Copyright 2012 The Go Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style | 2 // Use of this source code is governed by a BSD-style |
3 // license that can be found in the LICENSE file. | 3 // license that can be found in the LICENSE file. |
4 | 4 |
5 package agent | 5 package agent |
6 | 6 |
7 import ( | 7 import ( |
8 "bytes" | 8 "bytes" |
9 "crypto/rsa" | 9 "crypto/rsa" |
10 "crypto/x509" | 10 "crypto/x509" |
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
160 t.Errorf("Insert: %v", err) | 160 t.Errorf("Insert: %v", err) |
161 } | 161 } |
162 | 162 |
163 serverConf := ssh.ServerConfig{} | 163 serverConf := ssh.ServerConfig{} |
164 serverConf.AddHostKey(rsaKey) | 164 serverConf.AddHostKey(rsaKey) |
165 serverConf.PublicKeyCallback = func(c ssh.ConnMetadata, algo string, pub
key []byte) bool { | 165 serverConf.PublicKeyCallback = func(c ssh.ConnMetadata, algo string, pub
key []byte) bool { |
166 return bytes.Equal(pubkey, ssh.MarshalPublicKey(rsaKey.PublicKey
())) | 166 return bytes.Equal(pubkey, ssh.MarshalPublicKey(rsaKey.PublicKey
())) |
167 } | 167 } |
168 | 168 |
169 go func() { | 169 go func() { |
170 » » _, err := ssh.Server(a, &serverConf) | 170 » » conn, _, _, err := ssh.NewServerConn(a, &serverConf) |
171 if err != nil { | 171 if err != nil { |
172 t.Fatalf("Server: %v", err) | 172 t.Fatalf("Server: %v", err) |
173 } | 173 } |
| 174 conn.Close() |
174 }() | 175 }() |
175 | 176 |
176 conf := ssh.ClientConfig{} | 177 conf := ssh.ClientConfig{} |
177 conf.Auth = append(conf.Auth, ssh.ClientAuthKeyring(agent)) | 178 conf.Auth = append(conf.Auth, ssh.ClientAuthKeyring(agent)) |
178 » if _, err := ssh.Client(b, &conf); err != nil { | 179 » conn, _, _, err := ssh.NewClientConn(b, "", &conf) |
179 » » t.Fatalf("Client: %v", err) | 180 » if err != nil { |
| 181 » » t.Fatalf("NewClientConn: %v", err) |
180 } | 182 } |
| 183 conn.Close() |
181 } | 184 } |
OLD | NEW |