|
|
@ -1,9 +1,11 @@
|
|
|
|
package main
|
|
|
|
package main
|
|
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
import (
|
|
|
|
|
|
|
|
"code.google.com/p/go.crypto/ssh/terminal"
|
|
|
|
"crypto/rsa"
|
|
|
|
"crypto/rsa"
|
|
|
|
"encoding/json"
|
|
|
|
"encoding/json"
|
|
|
|
"fmt"
|
|
|
|
"fmt"
|
|
|
|
|
|
|
|
"io"
|
|
|
|
"net"
|
|
|
|
"net"
|
|
|
|
"os"
|
|
|
|
"os"
|
|
|
|
)
|
|
|
|
)
|
|
|
@ -17,7 +19,15 @@ func (a *Auth) Kind() string {
|
|
|
|
return "auth"
|
|
|
|
return "auth"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
type ReadWriter struct {
|
|
|
|
|
|
|
|
io.Reader
|
|
|
|
|
|
|
|
io.Writer
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func connect() {
|
|
|
|
func connect() {
|
|
|
|
|
|
|
|
if !terminal.IsTerminal(0) {
|
|
|
|
|
|
|
|
exit(1, "yeah you have to run this from a tty")
|
|
|
|
|
|
|
|
}
|
|
|
|
f, err := os.Open(options.key)
|
|
|
|
f, err := os.Open(options.key)
|
|
|
|
if err != nil {
|
|
|
|
if err != nil {
|
|
|
|
exit(1, "unable to open private key file at %s: %v", options.key, err)
|
|
|
|
exit(1, "unable to open private key file at %s: %v", options.key, err)
|
|
|
@ -39,6 +49,21 @@ func connect() {
|
|
|
|
Key: key.PublicKey,
|
|
|
|
Key: key.PublicKey,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
encodeRequest(conn, &auth)
|
|
|
|
encodeRequest(conn, &auth)
|
|
|
|
|
|
|
|
old, err := terminal.MakeRaw(0)
|
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
|
|
|
|
panic(err)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
defer terminal.Restore(0, old)
|
|
|
|
|
|
|
|
r := &ReadWriter{Reader: os.Stdin, Writer: os.Stdout}
|
|
|
|
|
|
|
|
term := terminal.NewTerminal(r, "> ")
|
|
|
|
|
|
|
|
|
|
|
|
fmt.Println(conn)
|
|
|
|
line, err := term.ReadLine()
|
|
|
|
|
|
|
|
switch err {
|
|
|
|
|
|
|
|
case io.EOF:
|
|
|
|
|
|
|
|
return
|
|
|
|
|
|
|
|
case nil:
|
|
|
|
|
|
|
|
fmt.Println(line)
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
|
|
|
exit(1, "error on line read: %v", err)
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|