@@ -158,13 +158,13 @@ class SSHServer {
158
158
}
159
159
160
160
// Create SSH connection to GitHub
161
- const githubSsh = new ssh2 . Client ( ) ;
161
+ const remoteGitSsh = new ssh2 . Client ( ) ;
162
162
163
163
console . log ( '[SSH] Creating SSH connection to GitHub' ) ;
164
164
165
165
// Add connection options
166
166
const connectionOptions = {
167
- host : 'github.com' ,
167
+ host : config . getProxyUrl ( ) . replace ( 'https://' , '' ) ,
168
168
port : 22 ,
169
169
username : 'git' ,
170
170
keepaliveInterval : 10000 , // Send keepalive every 10 seconds
@@ -176,6 +176,8 @@ class SSHServer {
176
176
} ,
177
177
} ;
178
178
179
+ console . log ( '[SSH] Connection options' , connectionOptions ) ;
180
+
179
181
// Get the client's SSH key that was used for authentication
180
182
const clientKey = session . _channel . _client . userPrivateKeyz ;
181
183
console . log ( '[SSH] Client key:' , clientKey ? 'Available' : 'Not available' ) ;
@@ -191,49 +193,54 @@ class SSHServer {
191
193
) ;
192
194
}
193
195
194
- githubSsh . on ( 'ready' , ( ) => {
196
+ remoteGitSsh . on ( 'ready' , ( ) => {
195
197
console . log ( '[SSH] Connected to GitHub' ) ;
196
198
197
199
// Execute the Git command on GitHub
198
- githubSsh . exec ( command , { env : { GIT_PROTOCOL : 'version=2' } } , ( err , githubStream ) => {
199
- if ( err ) {
200
- console . error ( '[SSH] Failed to execute command on GitHub:' , err ) ;
201
- stream . write ( err . toString ( ) ) ;
202
- stream . end ( ) ;
203
- return ;
204
- }
205
-
206
- // Handle stream errors
207
- githubStream . on ( 'error' , ( err ) => {
208
- console . error ( '[SSH] GitHub stream error:' , err ) ;
209
- stream . write ( err . toString ( ) ) ;
210
- stream . end ( ) ;
211
- } ) ;
212
-
213
- // Handle stream close
214
- githubStream . on ( 'close' , ( ) => {
215
- console . log ( '[SSH] GitHub stream closed' ) ;
216
- githubSsh . end ( ) ;
217
- } ) ;
218
-
219
- // Pipe data between client and GitHub
220
- stream . pipe ( githubStream ) . pipe ( stream ) ;
221
-
222
- githubStream . on ( 'exit' , ( code ) => {
223
- console . log ( `[SSH] GitHub command exited with code ${ code } ` ) ;
224
- githubSsh . end ( ) ;
225
- } ) ;
226
- } ) ;
200
+ remoteGitSsh . exec (
201
+ command ,
202
+ { env : { GIT_PROTOCOL : 'version=2' } } ,
203
+ ( err , githubStream ) => {
204
+ if ( err ) {
205
+ console . error ( '[SSH] Failed to execute command on GitHub:' , err ) ;
206
+ stream . write ( err . toString ( ) ) ;
207
+ stream . end ( ) ;
208
+ return ;
209
+ }
210
+
211
+ // Handle stream errors
212
+ githubStream . on ( 'error' , ( err ) => {
213
+ console . error ( '[SSH] GitHub stream error:' , err ) ;
214
+ stream . write ( err . toString ( ) ) ;
215
+ stream . end ( ) ;
216
+ } ) ;
217
+
218
+ // Handle stream close
219
+ githubStream . on ( 'close' , ( ) => {
220
+ console . log ( '[SSH] GitHub stream closed' ) ;
221
+ stream . pipe ( githubStream ) . pipe ( stream ) ;
222
+ remoteGitSsh . end ( ) ;
223
+ } ) ;
224
+
225
+ // Pipe data between client and GitHub
226
+ stream . pipe ( githubStream ) . pipe ( stream ) ;
227
+
228
+ githubStream . on ( 'exit' , ( code ) => {
229
+ console . log ( `[SSH] GitHub command exited with code ${ code } ` ) ;
230
+ remoteGitSsh . end ( ) ;
231
+ } ) ;
232
+ } ,
233
+ ) ;
227
234
} ) ;
228
235
229
- githubSsh . on ( 'error' , ( err ) => {
236
+ remoteGitSsh . on ( 'error' , ( err ) => {
230
237
console . error ( '[SSH] GitHub SSH error:' , err ) ;
231
238
stream . write ( err . toString ( ) ) ;
232
239
stream . end ( ) ;
233
240
} ) ;
234
241
235
242
// Connect to GitHub
236
- githubSsh . connect ( connectionOptions ) ;
243
+ remoteGitSsh . connect ( connectionOptions ) ;
237
244
} catch ( error ) {
238
245
console . error ( '[SSH] Error during SSH connection:' , error ) ;
239
246
stream . write ( error . toString ( ) ) ;
0 commit comments