Skip to content

Commit c048fe3

Browse files
henrybarretogustavosbarreto
authored andcommitted
ssh: revert TTY package to send messages during SSH connection
This reverts commit d014a00.
1 parent 65aabba commit c048fe3

File tree

2 files changed

+3
-102
lines changed

2 files changed

+3
-102
lines changed

ssh/pkg/tty/tty.go

Lines changed: 0 additions & 94 deletions
This file was deleted.

ssh/server/handler/ssh.go

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ import (
2020
"github.com/shellhub-io/shellhub/pkg/models"
2121
"github.com/shellhub-io/shellhub/ssh/pkg/flow"
2222
"github.com/shellhub-io/shellhub/ssh/pkg/metadata"
23-
"github.com/shellhub-io/shellhub/ssh/pkg/tty"
2423
"github.com/shellhub-io/shellhub/ssh/session"
2524
log "github.com/sirupsen/logrus"
2625
gossh "golang.org/x/crypto/ssh"
@@ -91,9 +90,9 @@ func SSHHandler(tunnel *httptunnel.Tunnel) gliderssh.Handler {
9190

9291
return
9392
}
93+
9494
defer sess.Finish() // nolint: errcheck
9595

96-
tty.Log(client, sess.Client, "starting SSH connection") //nolint:errcheck
9796
if wh := webhook.NewClient(); wh != nil {
9897
res, err := wh.Connect(sess.Lookup)
9998
if errors.Is(err, webhook.ErrForbidden) {
@@ -103,7 +102,7 @@ func SSHHandler(tunnel *httptunnel.Tunnel) gliderssh.Handler {
103102
}
104103

105104
if sess.Pty {
106-
tty.Log(client, sess.Client, fmt.Sprintf("wait %d seconds while the agent starts", res.Timeout)) //nolint:errcheck
105+
client.Write([]byte(fmt.Sprintf("Wait %d seconds while the agent starts\n", res.Timeout))) // nolint:errcheck
107106
}
108107

109108
time.Sleep(time.Duration(res.Timeout) * time.Second)
@@ -159,8 +158,7 @@ func SSHHandler(tunnel *httptunnel.Tunnel) gliderssh.Handler {
159158
}
160159
}
161160

162-
tty.Log(client, sess.Client, "connecting client to device...") //nolint: errcheck
163-
err = connectSSH(client.Context(), client, sess, config, api, opts)
161+
err = connectSSH(ctx, client, sess, config, api, opts)
164162
if err != nil {
165163
sendAndInformError(client, err, err)
166164

@@ -170,7 +168,6 @@ func SSHHandler(tunnel *httptunnel.Tunnel) gliderssh.Handler {
170168
}
171169

172170
func connectSSH(ctx context.Context, client gliderssh.Session, sess *session.Session, config *gossh.ClientConfig, api internalclient.Client, opts ConfigOptions) error {
173-
tty.Log(client, sess.Client, "authenticating to device...") //nolint:errcheck
174171
connection, reqs, err := sess.NewClientConnWithDeadline(config)
175172
if err != nil {
176173
return ErrAuthentication
@@ -191,7 +188,6 @@ func connectSSH(ctx context.Context, client gliderssh.Session, sess *session.Ses
191188

192189
metadata.MaybeStoreEstablished(ctx.(gliderssh.Context), true)
193190

194-
tty.Log(client, sess.Client, "requesting shell...") //nolint:errcheck
195191
pty, winCh, _ := client.Pty()
196192

197193
switch sess.GetType() {
@@ -255,7 +251,6 @@ func shell(api internalclient.Client, sess *session.Session, uid string, agent *
255251
}
256252
}()
257253

258-
tty.Reset(client, sess.Client) // nolint:errcheck
259254
flw, err := flow.NewFlow(agent)
260255
if err != nil {
261256
log.WithError(err).WithFields(log.Fields{

0 commit comments

Comments
 (0)