diff options
Diffstat (limited to 'modules/ssh/ssh.go')
-rw-r--r-- | modules/ssh/ssh.go | 30 |
1 files changed, 15 insertions, 15 deletions
diff --git a/modules/ssh/ssh.go b/modules/ssh/ssh.go index d9606488b2..f42c576cdb 100644 --- a/modules/ssh/ssh.go +++ b/modules/ssh/ssh.go @@ -43,7 +43,7 @@ func handleServerConn(keyID string, chans <-chan ssh.NewChannel) { ch, reqs, err := newChan.Accept() if err != nil { - log.Error(3, "Error accepting channel: %v", err) + log.Error("Error accepting channel: %v", err) continue } @@ -61,7 +61,7 @@ func handleServerConn(keyID string, chans <-chan ssh.NewChannel) { args[0] = strings.TrimLeft(args[0], "\x04") _, _, err := com.ExecCmdBytes("env", args[0]+"="+args[1]) if err != nil { - log.Error(3, "env: %v", err) + log.Error("env: %v", err) return } case "exec": @@ -79,23 +79,23 @@ func handleServerConn(keyID string, chans <-chan ssh.NewChannel) { stdout, err := cmd.StdoutPipe() if err != nil { - log.Error(3, "SSH: StdoutPipe: %v", err) + log.Error("SSH: StdoutPipe: %v", err) return } stderr, err := cmd.StderrPipe() if err != nil { - log.Error(3, "SSH: StderrPipe: %v", err) + log.Error("SSH: StderrPipe: %v", err) return } input, err := cmd.StdinPipe() if err != nil { - log.Error(3, "SSH: StdinPipe: %v", err) + log.Error("SSH: StdinPipe: %v", err) return } // FIXME: check timeout if err = cmd.Start(); err != nil { - log.Error(3, "SSH: Start: %v", err) + log.Error("SSH: Start: %v", err) return } @@ -105,7 +105,7 @@ func handleServerConn(keyID string, chans <-chan ssh.NewChannel) { io.Copy(ch.Stderr(), stderr) if err = cmd.Wait(); err != nil { - log.Error(3, "SSH: Wait: %v", err) + log.Error("SSH: Wait: %v", err) return } @@ -121,13 +121,13 @@ func handleServerConn(keyID string, chans <-chan ssh.NewChannel) { func listen(config *ssh.ServerConfig, host string, port int) { listener, err := net.Listen("tcp", host+":"+com.ToStr(port)) if err != nil { - log.Fatal(4, "Failed to start SSH server: %v", err) + log.Fatal("Failed to start SSH server: %v", err) } for { // Once a ServerConfig has been configured, connections can be accepted. conn, err := listener.Accept() if err != nil { - log.Error(3, "SSH: Error accepting incoming connection: %v", err) + log.Error("SSH: Error accepting incoming connection: %v", err) continue } @@ -142,7 +142,7 @@ func listen(config *ssh.ServerConfig, host string, port int) { if err == io.EOF { log.Warn("SSH: Handshaking with %s was terminated: %v", conn.RemoteAddr(), err) } else { - log.Error(3, "SSH: Error on handshaking with %s: %v", conn.RemoteAddr(), err) + log.Error("SSH: Error on handshaking with %s: %v", conn.RemoteAddr(), err) } return } @@ -166,7 +166,7 @@ func Listen(host string, port int, ciphers []string, keyExchanges []string, macs PublicKeyCallback: func(conn ssh.ConnMetadata, key ssh.PublicKey) (*ssh.Permissions, error) { pkey, err := models.SearchPublicKeyByContent(strings.TrimSpace(string(ssh.MarshalAuthorizedKey(key)))) if err != nil { - log.Error(3, "SearchPublicKeyByContent: %v", err) + log.Error("SearchPublicKeyByContent: %v", err) return nil, err } return &ssh.Permissions{Extensions: map[string]string{"key-id": com.ToStr(pkey.ID)}}, nil @@ -178,23 +178,23 @@ func Listen(host string, port int, ciphers []string, keyExchanges []string, macs filePath := filepath.Dir(keyPath) if err := os.MkdirAll(filePath, os.ModePerm); err != nil { - log.Error(4, "Failed to create dir %s: %v", filePath, err) + log.Error("Failed to create dir %s: %v", filePath, err) } err := GenKeyPair(keyPath) if err != nil { - log.Fatal(4, "Failed to generate private key: %v", err) + log.Fatal("Failed to generate private key: %v", err) } log.Trace("SSH: New private key is generateed: %s", keyPath) } privateBytes, err := ioutil.ReadFile(keyPath) if err != nil { - log.Fatal(4, "SSH: Failed to load private key") + log.Fatal("SSH: Failed to load private key") } private, err := ssh.ParsePrivateKey(privateBytes) if err != nil { - log.Fatal(4, "SSH: Failed to parse private key") + log.Fatal("SSH: Failed to parse private key") } config.AddHostKey(private) |