@@ -81,7 +81,7 @@ func startSshServer() {
81
81
}
82
82
83
83
// Seems next can some time. Not block listening loop
84
- go handleChannels (sshConn , channels )
84
+ go handleChannels (* sshConn , channels )
85
85
}
86
86
}
87
87
@@ -116,12 +116,12 @@ func publicKeyCallback(sshConn ssh.ConnMetadata, remoteKey ssh.PublicKey) (*ssh.
116
116
log .Printf ("Public key math: %s" , username )
117
117
return nil , nil
118
118
}
119
- return nil , errors .New ("Not authorized key" )
119
+ return nil , errors .New ("not authorized key" )
120
120
}
121
121
122
122
// This is called for already authenticated(via publicKeyCallback) users
123
123
// Handles receiving a token from the user
124
- func handleChannels (sshConn ssh.ConnMetadata , channels <- chan ssh.NewChannel ) {
124
+ func handleChannels (sshConn ssh.ServerConn , channels <- chan ssh.NewChannel ) {
125
125
for newChannel := range channels {
126
126
// Channels have a type, depending on the application level protocol intended.
127
127
// In the case of a shell, the type is "session" and ServerShell may be used
@@ -196,7 +196,11 @@ func handleChannels(sshConn ssh.ConnMetadata, channels <-chan ssh.NewChannel) {
196
196
break
197
197
}
198
198
}
199
+ // Send exit code: 0 - success
200
+ // 4 zeros because answer must be uint32 (4 bytes)
201
+ channel .SendRequest ("exit-status" , false , []byte {0 ,0 ,0 ,0 })
199
202
channel .Close ()
203
+ sshConn .Close ()
200
204
// Lock and modify global var
201
205
ssh_tokens_mutex .Lock ()
202
206
delete (ssh_tokens , sshToken )
0 commit comments