File size: 41,146 Bytes
72268ee
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
    "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta name="generator" content="AsciiDoc 8.5.2" />
<title>SSH Proxy Command&#8201;&#8212;&#8201;connect.c</title>
<style type="text/css">
/* Debug borders */
p, li, dt, dd, div, pre, h1, h2, h3, h4, h5, h6 {
/*
  border: 1px solid red;
*/
}

body {
  margin: 1em 5% 1em 5%;
}

a {
  color: blue;
  text-decoration: underline;
}
a:visited {
  color: fuchsia;
}

em {
  font-style: italic;
  color: navy;
}

strong {
  font-weight: bold;
  color: #083194;
}

tt {
  color: navy;
}

h1, h2, h3, h4, h5, h6 {
  color: #527bbd;
  font-family: sans-serif;
  margin-top: 1.2em;
  margin-bottom: 0.5em;
  line-height: 1.3;
}

h1, h2, h3 {
  border-bottom: 2px solid silver;
}
h2 {
  padding-top: 0.5em;
}
h3 {
  float: left;
}
h3 + * {
  clear: left;
}

div.sectionbody {
  font-family: serif;
  margin-left: 0;
}

hr {
  border: 1px solid silver;
}

p {
  margin-top: 0.5em;
  margin-bottom: 0.5em;
}

ul, ol, li > p {
  margin-top: 0;
}

pre {
  padding: 0;
  margin: 0;
}

span#author {
  color: #527bbd;
  font-family: sans-serif;
  font-weight: bold;
  font-size: 1.1em;
}
span#email {
}
span#revnumber, span#revdate, span#revremark {
  font-family: sans-serif;
}

div#footer {
  font-family: sans-serif;
  font-size: small;
  border-top: 2px solid silver;
  padding-top: 0.5em;
  margin-top: 4.0em;
}
div#footer-text {
  float: left;
  padding-bottom: 0.5em;
}
div#footer-badges {
  float: right;
  padding-bottom: 0.5em;
}

div#preamble {
  margin-top: 1.5em;
  margin-bottom: 1.5em;
}
div.tableblock, div.imageblock, div.exampleblock, div.verseblock,
div.quoteblock, div.literalblock, div.listingblock, div.sidebarblock,
div.admonitionblock {
  margin-top: 1.0em;
  margin-bottom: 1.5em;
}
div.admonitionblock {
  margin-top: 2.0em;
  margin-bottom: 2.0em;
  margin-right: 10%;
  color: #606060;
}

div.content { /* Block element content. */
  padding: 0;
}

/* Block element titles. */
div.title, caption.title {
  color: #527bbd;
  font-family: sans-serif;
  font-weight: bold;
  text-align: left;
  margin-top: 1.0em;
  margin-bottom: 0.5em;
}
div.title + * {
  margin-top: 0;
}

td div.title:first-child {
  margin-top: 0.0em;
}
div.content div.title:first-child {
  margin-top: 0.0em;
}
div.content + div.title {
  margin-top: 0.0em;
}

div.sidebarblock > div.content {
  background: #ffffee;
  border: 1px solid silver;
  padding: 0.5em;
}

div.listingblock > div.content {
  border: 1px solid silver;
  background: #f4f4f4;
  padding: 0.5em;
}

div.quoteblock, div.verseblock {
  padding-left: 1.0em;
  margin-left: 1.0em;
  margin-right: 10%;
  border-left: 5px solid #dddddd;
  color: #777777;
}

div.quoteblock > div.attribution {
  padding-top: 0.5em;
  text-align: right;
}

div.verseblock > div.content {
  white-space: pre;
}
div.verseblock > div.attribution {
  padding-top: 0.75em;
  text-align: left;
}
/* DEPRECATED: Pre version 8.2.7 verse style literal block. */
div.verseblock + div.attribution {
  text-align: left;
}

div.admonitionblock .icon {
  vertical-align: top;
  font-size: 1.1em;
  font-weight: bold;
  text-decoration: underline;
  color: #527bbd;
  padding-right: 0.5em;
}
div.admonitionblock td.content {
  padding-left: 0.5em;
  border-left: 3px solid #dddddd;
}

div.exampleblock > div.content {
  border-left: 3px solid #dddddd;
  padding-left: 0.5em;
}

div.imageblock div.content { padding-left: 0; }
span.image img { border-style: none; }
a.image:visited { color: white; }

dl {
  margin-top: 0.8em;
  margin-bottom: 0.8em;
}
dt {
  margin-top: 0.5em;
  margin-bottom: 0;
  font-style: normal;
  color: navy;
}
dd > *:first-child {
  margin-top: 0.1em;
}

ul, ol {
    list-style-position: outside;
}
ol.arabic {
  list-style-type: decimal;
}
ol.loweralpha {
  list-style-type: lower-alpha;
}
ol.upperalpha {
  list-style-type: upper-alpha;
}
ol.lowerroman {
  list-style-type: lower-roman;
}
ol.upperroman {
  list-style-type: upper-roman;
}

div.compact ul, div.compact ol,
div.compact p, div.compact p,
div.compact div, div.compact div {
  margin-top: 0.1em;
  margin-bottom: 0.1em;
}

div.tableblock > table {
  border: 3px solid #527bbd;
}
thead, p.table.header {
  font-family: sans-serif;
  font-weight: bold;
}
tfoot {
  font-weight: bold;
}
td > div.verse {
  white-space: pre;
}
p.table {
  margin-top: 0;
}
/* Because the table frame attribute is overriden by CSS in most browsers. */
div.tableblock > table[frame="void"] {
  border-style: none;
}
div.tableblock > table[frame="hsides"] {
  border-left-style: none;
  border-right-style: none;
}
div.tableblock > table[frame="vsides"] {
  border-top-style: none;
  border-bottom-style: none;
}


div.hdlist {
  margin-top: 0.8em;
  margin-bottom: 0.8em;
}
div.hdlist tr {
  padding-bottom: 15px;
}
dt.hdlist1.strong, td.hdlist1.strong {
  font-weight: bold;
}
td.hdlist1 {
  vertical-align: top;
  font-style: normal;
  padding-right: 0.8em;
  color: navy;
}
td.hdlist2 {
  vertical-align: top;
}
div.hdlist.compact tr {
  margin: 0;
  padding-bottom: 0;
}

.comment {
  background: yellow;
}

.footnote, .footnoteref {
  font-size: 0.8em;
}

span.footnote, span.footnoteref {
  vertical-align: super;
}

#footnotes {
  margin: 20px 0 20px 0;
  padding: 7px 0 0 0;
}

#footnotes div.footnote {
  margin: 0 0 5px 0;
}

#footnotes hr {
  border: none;
  border-top: 1px solid silver;
  height: 1px;
  text-align: left;
  margin-left: 0;
  width: 20%;
  min-width: 100px;
}


@media print {
  div#footer-badges { display: none; }
}

div#toc {
  margin-bottom: 2.5em;
}

div#toctitle {
  color: #527bbd;
  font-family: sans-serif;
  font-size: 1.1em;
  font-weight: bold;
  margin-top: 1.0em;
  margin-bottom: 0.1em;
}

div.toclevel1, div.toclevel2, div.toclevel3, div.toclevel4 {
  margin-top: 0;
  margin-bottom: 0;
}
div.toclevel2 {
  margin-left: 2em;
  font-size: 0.9em;
}
div.toclevel3 {
  margin-left: 4em;
  font-size: 0.9em;
}
div.toclevel4 {
  margin-left: 6em;
  font-size: 0.9em;
}
/* Workarounds for IE6's broken and incomplete CSS2. */

div.sidebar-content {
  background: #ffffee;
  border: 1px solid silver;
  padding: 0.5em;
}
div.sidebar-title, div.image-title {
  color: #527bbd;
  font-family: sans-serif;
  font-weight: bold;
  margin-top: 0.0em;
  margin-bottom: 0.5em;
}

div.listingblock div.content {
  border: 1px solid silver;
  background: #f4f4f4;
  padding: 0.5em;
}

div.quoteblock-attribution {
  padding-top: 0.5em;
  text-align: right;
}

div.verseblock-content {
  white-space: pre;
}
div.verseblock-attribution {
  padding-top: 0.75em;
  text-align: left;
}

div.exampleblock-content {
  border-left: 3px solid #dddddd;
  padding-left: 0.5em;
}

/* IE6 sets dynamically generated links as visited. */
div#toc a:visited { color: blue; }
</style>
<script type="text/javascript">
/*<![CDATA[*/
window.onload = function(){asciidoc.footnotes();}
var asciidoc = {  // Namespace.

/////////////////////////////////////////////////////////////////////
// Table Of Contents generator
/////////////////////////////////////////////////////////////////////

/* Author: Mihai Bazon, September 2002
 * http://students.infoiasi.ro/~mishoo
 *
 * Table Of Content generator
 * Version: 0.4
 *
 * Feel free to use this script under the terms of the GNU General Public
 * License, as long as you do not remove or alter this notice.
 */

 /* modified by Troy D. Hanson, September 2006. License: GPL */
 /* modified by Stuart Rackham, 2006, 2009. License: GPL */

// toclevels = 1..4.
toc: function (toclevels) {

  function getText(el) {
    var text = "";
    for (var i = el.firstChild; i != null; i = i.nextSibling) {
      if (i.nodeType == 3 /* Node.TEXT_NODE */) // IE doesn't speak constants.
        text += i.data;
      else if (i.firstChild != null)
        text += getText(i);
    }
    return text;
  }

  function TocEntry(el, text, toclevel) {
    this.element = el;
    this.text = text;
    this.toclevel = toclevel;
  }

  function tocEntries(el, toclevels) {
    var result = new Array;
    var re = new RegExp('[hH]([2-'+(toclevels+1)+'])');
    // Function that scans the DOM tree for header elements (the DOM2
    // nodeIterator API would be a better technique but not supported by all
    // browsers).
    var iterate = function (el) {
      for (var i = el.firstChild; i != null; i = i.nextSibling) {
        if (i.nodeType == 1 /* Node.ELEMENT_NODE */) {
          var mo = re.exec(i.tagName);
          if (mo && (i.getAttribute("class") || i.getAttribute("className")) != "float") {
            result[result.length] = new TocEntry(i, getText(i), mo[1]-1);
          }
          iterate(i);
        }
      }
    }
    iterate(el);
    return result;
  }

  var toc = document.getElementById("toc");
  var entries = tocEntries(document.getElementById("content"), toclevels);
  for (var i = 0; i < entries.length; ++i) {
    var entry = entries[i];
    if (entry.element.id == "")
      entry.element.id = "_toc_" + i;
    var a = document.createElement("a");
    a.href = "#" + entry.element.id;
    a.appendChild(document.createTextNode(entry.text));
    var div = document.createElement("div");
    div.appendChild(a);
    div.className = "toclevel" + entry.toclevel;
    toc.appendChild(div);
  }
  if (entries.length == 0)
    toc.parentNode.removeChild(toc);
},


/////////////////////////////////////////////////////////////////////
// Footnotes generator
/////////////////////////////////////////////////////////////////////

/* Based on footnote generation code from:
 * http://www.brandspankingnew.net/archive/2005/07/format_footnote.html
 */

footnotes: function () {
  var cont = document.getElementById("content");
  var noteholder = document.getElementById("footnotes");
  var spans = cont.getElementsByTagName("span");
  var refs = {};
  var n = 0;
  for (i=0; i<spans.length; i++) {
    if (spans[i].className == "footnote") {
      n++;
      // Use [\s\S] in place of . so multi-line matches work.
      // Because JavaScript has no s (dotall) regex flag.
      note = spans[i].innerHTML.match(/\s*\[([\s\S]*)]\s*/)[1];
      noteholder.innerHTML +=
        "<div class='footnote' id='_footnote_" + n + "'>" +
        "<a href='#_footnoteref_" + n + "' title='Return to text'>" +
        n + "</a>. " + note + "</div>";
      spans[i].innerHTML =
        "[<a id='_footnoteref_" + n + "' href='#_footnote_" + n +
        "' title='View footnote' class='footnote'>" + n + "</a>]";
      var id =spans[i].getAttribute("id");
      if (id != null) refs["#"+id] = n;
    }
  }
  if (n == 0)
    noteholder.parentNode.removeChild(noteholder);
  else {
    // Process footnoterefs.
    for (i=0; i<spans.length; i++) {
      if (spans[i].className == "footnoteref") {
        var href = spans[i].getElementsByTagName("a")[0].getAttribute("href");
        href = href.match(/#.*/)[0];  // Because IE return full URL.
        n = refs[href];
        spans[i].innerHTML =
          "[<a href='#_footnote_" + n +
          "' title='View footnote' class='footnote'>" + n + "</a>]";
      }
    }
  }
}

}
/*]]>*/
</script>
</head>
<body>
<div id="header">
<h1>SSH Proxy Command&#8201;&#8212;&#8201;connect.c</h1>
</div>
<div id="content">
<div id="preamble">
<div class="sectionbody">
<div class="paragraph"><p><tt>connect.c</tt> is a simple relaying command to make network connection
via SOCKS and https proxy. It is mainly intended to be used as proxy
command of OpenSSH. You can make SSH session beyond the firewall with
this command,</p></div>
<div class="paragraph"><p>Features of <tt>connect.c</tt> are:</p></div>
<div class="ulist"><ul>
<li>
<p>
Supports SOCKS (version 4/4a/5) and https CONNECT method.
</p>
</li>
<li>
<p>
Supports NO-AUTH and USERPASS authentication of SOCKS5
</p>
</li>
<li>
<p>
You can input password from tty, <tt>ssh-askpass</tt> or environment variable.
</p>
</li>
<li>
<p>
Run on UNIX or Windows platform.
</p>
</li>
<li>
<p>
You can compile with various C compiler (cc, gcc, Visual C, Borland C. etc.)
</p>
</li>
<li>
<p>
Simple and general program independent from OpenSSH.
</p>
</li>
<li>
<p>
You can also relay local socket stream instead of standard I/O.
</p>
</li>
</ul></div>
<div class="paragraph"><p>You can download source code
(<a href="http://bitbucket.org/gotoh/connect/raw/tip/connect.c">connect.c</a>)
on the <a href="http://bitbucket.org/gotoh/connect/">project page</a>.</p></div>
<div class="paragraph"><p>Pre-compiled binary for MS Windows is also available on
<a href="http://bitbucket.org/gotoh/connect/downloads/">download page</a>.</p></div>
</div>
</div>
<h2 id="_what_is_proxy_command">What is proxy command?</h2>
<div class="sectionbody">
<div class="paragraph"><p>OpenSSH development team decides to stop supporting SOCKS and any
other tunneling mechanism. It was aimed to separate complexity to
support various mechanism of proxying from core code. And they
recommends more flexible mechanism: ProxyCommand option instead.</p></div>
<div class="paragraph"><p>Proxy command mechanism is delegation of network stream
communication. If ProxyCommand options is specified, SSH invoke
specified external command and talk with standard I/O of thid
command. Invoked command undertakes network communication with
relaying to/from standard input/output including iniitial
communication or negotiation for proxying. Thus, ssh can split out
proxying code into external command.</p></div>
<div class="paragraph"><p>The <tt>connect.c</tt> program was made for this purpose.</p></div>
</div>
<h2 id="_how_to_use">How to Use</h2>
<div class="sectionbody">
<h3 id="_get_source">Get Source</h3><div style="clear:left"></div>
<div class="paragraph"><p>You can get source code from <a href="http://bitbucket.org/gotoh/connect/downloads/">project download page</a>.
Pre-compiled MS Windows binary is also available there.</p></div>
<h3 id="_compile_and_install">Compile and Install</h3><div style="clear:left"></div>
<div class="paragraph"><p>In most environment, you can compile <tt>connect.c</tt> simply. On UNIX
environment, you can use cc or gcc. On Windows environment, you can
use Microsoft Visual C, Borland C or Cygwin gcc.</p></div>
<div class="dlist"><dl>
<dt class="hdlist1">
UNIX cc
</dt>
<dd>
<p>
<tt>cc connect.c -o connect</tt>
</p>
</dd>
<dt class="hdlist1">
UNIX gcc
</dt>
<dd>
<p>
<tt>gcc connect.c -o connect</tt>
</p>
</dd>
<dt class="hdlist1">
Solaris
</dt>
<dd>
<p>
<tt>gcc connect.c -o connect -lnsl -lsocket -lresolv</tt>
</p>
</dd>
<dt class="hdlist1">
Microsoft Visual C/C++
</dt>
<dd>
<p>
<tt>cl connect.c wsock32.lib advapi32.lib</tt>
</p>
</dd>
<dt class="hdlist1">
Borland C
</dt>
<dd>
<p>
<tt>bcc32 connect.c wsock32.lib advapi32.lib</tt>
</p>
</dd>
<dt class="hdlist1">
Cygwin gcc
</dt>
<dd>
<p>
<tt>gcc connect.c -o connect</tt>
</p>
</dd>
<dt class="hdlist1">
Mac OS/Darwin
</dt>
<dd>
<p>
<tt>gcc connect.c -o connect -lresolv</tt>
</p>
</dd>
</dl></div>
<div class="paragraph"><p>To install connect command, simply copy compiled binary to directory
in your <tt>PATH</tt> (ex. <tt>/usr/local/bin</tt>). Like this:</p></div>
<div class="listingblock">
<div class="content">
<pre><tt>$ cp connect /usr/local/bin</tt></pre>
</div></div>
<h3 id="_modify_your_tt_ssh_config_tt">Modify your <tt>~/.ssh/config</tt></h3><div style="clear:left"></div>
<div class="paragraph"><p>Modify your <tt>~/.ssh/config</tt> file to use connect command as proxy
command. For the case of SOCKS server is running on firewall host
socks.local.net with port 1080, you can add <tt>ProxyCommand</tt> option in
<tt>~/.ssh/config</tt>, like this:</p></div>
<div class="listingblock">
<div class="content">
<pre><tt>Host remote.outside.net
  ProxyCommand connect -S socks.local.net %h %p</tt></pre>
</div></div>
<div class="paragraph"><p><tt>%h</tt> and <tt>%p</tt> will be replaced on invoking proxy command with target
hostname and port specified to SSH command.</p></div>
<div class="paragraph"><p>If you hate writing many entries of remote hosts, following example
may help you.</p></div>
<div class="listingblock">
<div class="content">
<pre><tt>## Outside of the firewall, use connect command with SOCKS conenction.
Host *
  ProxyCommand connect -S socks.local.net %h %p

## Inside of the firewall, use connect command with direct connection.
Host *.local.net
  ProxyCommand connect %h %p</tt></pre>
</div></div>
<div class="paragraph"><p>If you want to use http proxy, use <tt>-H</tt> option instead of <tt>-S</tt> option
in examle above, like this:</p></div>
<div class="listingblock">
<div class="content">
<pre><tt>## Outside of the firewall, with HTTP proxy
Host *
  ProxyCommand connect -H proxy.local.net:8080 %h %p

## Inside of the firewall, direct
Host *.local.net
  ProxyCommand connect %h %p</tt></pre>
</div></div>
<h3 id="_use_ssh">Use SSH</h3><div style="clear:left"></div>
<div class="paragraph"><p>After editing your <tt>~/.ssh/config</tt> file, you are ready to use ssh. You
can execute ssh without any special options as if remote host is IP
reachable host. Following is an example to execute hostname command on
host <tt>remote.outside.net</tt>.</p></div>
<div class="listingblock">
<div class="content">
<pre><tt>local$ ssh remote.outside.net hostname
Hello, this is remote.outside.net
remote$</tt></pre>
</div></div>
<h3 id="_have_trouble">Have trouble?</h3><div style="clear:left"></div>
<div class="paragraph"><p>If you have trouble, execute connect command from command line with <tt>-d</tt>
option to see what is happened. Some debug message may appear and
reports progress. This information may tell you what is wrong. In this
example, error has occurred on authentication stage of SOCKS5
protocol.</p></div>
<div class="listingblock">
<div class="content">
<pre><tt>$ connect -d -S socks.local.net unknown.remote.outside.net 110
DEBUG: relay_method = SOCKS (2)
DEBUG: relay_host=socks.local.net
DEBUG: relay_port=1080
DEBUG: relay_user=gotoh
DEBUG: socks_version=5
DEBUG: socks_resolve=REMOTE (2)
DEBUG: local_type=stdio
DEBUG: dest_host=unknown.remote.outside.net
DEBUG: dest_port=110
DEBUG: Program is $Revision: 1.20 $
DEBUG: connecting to xxx.xxx.xxx.xxx:1080
DEBUG: begin_socks_relay()
DEBUG: atomic_out()  [4 bytes]
DEBUG: &gt;&gt;&gt; 05 02 00 02
DEBUG: atomic_in() [2 bytes]
DEBUG: &lt;&lt;&lt; 05 02
DEBUG: auth method: USERPASS
DEBUG: atomic_out()  [some bytes]
DEBUG: &gt;&gt;&gt; xx xx xx xx ...
DEBUG: atomic_in() [2 bytes]
DEBUG: &lt;&lt;&lt; 01 01
ERROR: Authentication faield.
FATAL: failed to begin relaying via SOCKS.</tt></pre>
</div></div>
</div>
<h2 id="_more_detail">More Detail</h2>
<div class="sectionbody">
<div class="paragraph"><p>Command line usage is here:</p></div>
<div class="listingblock">
<div class="content">
<pre><tt>usage:  connect [-dnhs45] [-R resolve] [-p local-port] [-w sec]
                [-H [user@]proxy-server[:port]]
                [-S [user@]socks-server[:port]]
                host port</tt></pre>
</div></div>
<div class="paragraph"><p>host and port is target hostname and port-number to connect.</p></div>
<div class="dlist"><dl>
<dt class="hdlist1">
<tt>-H</tt> [user@]server[:port]
</dt>
<dd>
<p>
  Specify hostname and port number of http proxy server to
  relay. If port is omitted, 80 is used.
</p>
</dd>
<dt class="hdlist1">
<tt>-h</tt>
</dt>
<dd>
<p>
  Use HTTP proxy via proxy server sepcified by environment variable
  <tt>HTTP_PROXY</tt>.
</p>
</dd>
<dt class="hdlist1">
<tt>-S</tt> [_user_@]<em>server</em>\[:_port_]
</dt>
<dd>
<p>
  Specify hostname and port number of SOCKS server to
  relay. Like <tt>-H</tt> option, port number can be omit and default is 1080.
</p>
</dd>
<dt class="hdlist1">
<tt>-s</tt>
</dt>
<dd>
<p>
  Use SOCKS proxy via SOCKS server sepcified by environment variable
  <tt>SOCKS5_SERVER</tt>.
</p>
</dd>
<dt class="hdlist1">
<tt>-4</tt>
</dt>
<dd>
<p>
Use SOCKS version 4 protocol.
  This option must be used with <tt>-S</tt>.
</p>
</dd>
<dt class="hdlist1">
<tt>-5</tt>
</dt>
<dd>
<p>
Use SOCKS version 5 protocol.
  This option must be used with <tt>-S</tt>.
</p>
</dd>
<dt class="hdlist1">
<tt>-R</tt> <em>method</em>
</dt>
<dd>
<p>
The method to resolve hostname.  3 keywords (<tt>local</tt>,
  <tt>remote</tt>, <tt>both</tt>) or dot-notation IP address is allowed. Keyword
  both means; <em>"Try local first, then remote"</em>. If dot-notation IP
  address is specified, use this host as nameserver (UNIX
  only). Default is remote for SOCKS5 or local for others. On SOCKS4
  protocol, remote resolving method (remote and both) use protocol
  version 4a.
</p>
</dd>
<dt class="hdlist1">
<tt>-p</tt> <em>port</em>
</dt>
<dd>
<p>
Accept on local TCP port and relay it instead of standard input
and output. With this option, program will terminate when remote or
local TCP session is closed.
</p>
</dd>
<dt class="hdlist1">
<tt>-w</tt> <em>timeout</em>
</dt>
<dd>
<p>
Timeout seconds for connecting to remote host.
</p>
</dd>
<dt class="hdlist1">
<tt>-a</tt> <em>auth</em>
</dt>
<dd>
<p>
option specifiys user intended authentication methods
separated by comma. Currently <tt>userpass</tt> and <tt>none</tt> are
supported. Default is userpass. You can also specifying this parameter
by the environment variable <tt>SOCKS5_AUTH</tt>.
</p>
</dd>
</dl></div>
<div class="paragraph"><p><tt>-d</tt>: Run with debug message output. If you fail to connect, use this
option to see what is done.</p></div>
<div class="paragraph"><p>As additional feature,
you can omit port argument when program name is special format
containing port number itself like "connect-25". For example:</p></div>
<div class="listingblock">
<div class="content">
<pre><tt>$ ln -s connect connect-25
$ ./connect-25 smtphost.outside.net
220 smtphost.outside.net ESMTP Sendmail
QUIT
221 2.0.0 smtphost.remote.net closing connection
$</tt></pre>
</div></div>
<div class="paragraph"><p>This example means that the command name "connect-25" indicates port
number 25 so you can omit 2nd argument (and used if specified
explicitly).
This is usefull for the application which invokes only with hostname
argument.</p></div>
<h3 id="_specifying_user_name_via_environment_variables">Specifying user name via environment variables</h3><div style="clear:left"></div>
<div class="paragraph"><p>There are 5 environemnt variables to specify user name without command
line option. This mechanism is usefull for the user who using another
user name different from system account.</p></div>
<div class="dlist"><dl>
<dt class="hdlist1">
<tt>SOCKS5_USER</tt>
</dt>
<dd>
<p>
    Used for SOCKS v5 access.
</p>
</dd>
<dt class="hdlist1">
<tt>SOCKS4_USER</tt>
</dt>
<dd>
<p>
    Used for SOCKS v4 access.
</p>
</dd>
<dt class="hdlist1">
<tt>SOCKS_USER</tt>
</dt>
<dd>
<p>
    Used for SOCKS v5 or v4 access and varaibles above are not defined.
</p>
</dd>
<dt class="hdlist1">
<tt>HTTP_PROXY_USER</tt>
</dt>
<dd>
<p>
    Used for HTTP proxy access.
</p>
</dd>
<dt class="hdlist1">
<tt>CONNECT_USER</tt>
</dt>
<dd>
<p>
    Used for all type of access if all above are not defined.
</p>
</dd>
</dl></div>
<div class="paragraph"><p>Following table describes how user name is determined. Left most number is order to check. If variable is not defined, check next variable, and so on.</p></div>
<div class="tableblock">
<table rules="all"
width="50%"
frame="border"
cellspacing="0" cellpadding="4">
<col width="25%" />
<col width="25%" />
<col width="25%" />
<col width="25%" />
<tbody>
<tr>
<td align="left" valign="top"><p class="table"></p></td>
<td align="left" valign="top"><p class="table">SOCKS v5</p></td>
<td align="left" valign="top"><p class="table">SOCKS v4</p></td>
<td align="left" valign="top"><p class="table">HTTP proxy</p></td>
</tr>
<tr>
<td align="left" valign="top"><p class="table">1</p></td>
<td align="left" valign="top"><p class="table"><tt>SOCKS5_USER</tt></p></td>
<td align="left" valign="top"><p class="table"><tt>SOCKS4_USER</tt></p></td>
<td rowspan="2" align="center" valign="top"><p class="table"><tt>HTTP_PROXY_USER</tt></p></td>
</tr>
<tr>
<td align="left" valign="top"><p class="table">2</p></td>
<td colspan="2" align="center" valign="top"><p class="table"><tt>SOCKS_USER</tt></p></td>
</tr>
<tr>
<td align="left" valign="top"><p class="table">3</p></td>
<td colspan="3" align="center" valign="top"><p class="table"><tt>CONNECT_USER</tt></p></td>
</tr>
<tr>
<td align="left" valign="top"><p class="table">4</p></td>
<td colspan="3" align="center" valign="top"><p class="table">(query user name to system)</p></td>
</tr>
</tbody>
</table>
</div>
<h3 id="_specifying_password_via_environment_variables">Specifying password via environment variables</h3><div style="clear:left"></div>
<div class="paragraph"><p>There are 5 environemnt variables to specify password. If you use this
feature, please note that it is not secure way.</p></div>
<div class="dlist"><dl>
<dt class="hdlist1">
<tt>SOCKS5_PASSWD</tt>
</dt>
<dd>
<p>
    Used for SOCKS v5 access. This variables is compatible with NEC SOCKS implementation.
</p>
</dd>
<dt class="hdlist1">
<tt>SOCKS5_PASSWORD</tt>
</dt>
<dd>
<p>
    Used for SOCKS v5 access if <tt>SOCKS5_PASSWD</tt> is not defined.
</p>
</dd>
<dt class="hdlist1">
<tt>SOCKS_PASSWORD</tt>
</dt>
<dd>
<p>
    Used for SOCKS v5 (or v4) access all above is not defined.
</p>
</dd>
<dt class="hdlist1">
<tt>HTTP_PROXY_PASSWORD</tt>
</dt>
<dd>
<p>
    Used for HTTP proxy access.
</p>
</dd>
<dt class="hdlist1">
<tt>CONNECT_PASSWORD</tt>
</dt>
<dd>
<p>
    Used for all type of access if all above are not defined.
</p>
</dd>
</dl></div>
<div class="paragraph"><p>Following table describes how password is determined. Left most number
is order to check. If variable is not defined, check next variable,
and so on. Finally ask to user interactively using external program or
tty input.</p></div>
<div class="tableblock">
<table rules="all"
width="50%"
frame="border"
cellspacing="0" cellpadding="4">
<col width="33%" />
<col width="33%" />
<col width="33%" />
<tbody>
<tr>
<td align="left" valign="top"><p class="table"></p></td>
<td align="left" valign="top"><p class="table">SOCKS v5</p></td>
<td align="left" valign="top"><p class="table">HTTP proxy</p></td>
</tr>
<tr>
<td align="left" valign="top"><p class="table">1</p></td>
<td align="left" valign="top"><p class="table"><tt>SOCKS5_PASSWD</tt></p></td>
<td rowspan="2" align="center" valign="top"><p class="table"><tt>HTTP_PROXY_PASSWORD</tt></p></td>
</tr>
<tr>
<td align="left" valign="top"><p class="table">2</p></td>
<td align="left" valign="top"><p class="table"><tt>SOCKS_PASSWORD</tt></p></td>
</tr>
<tr>
<td align="left" valign="top"><p class="table">3</p></td>
<td colspan="2" align="center" valign="top"><p class="table"><tt>CONNECT_PASSWORD</tt></p></td>
</tr>
<tr>
<td align="left" valign="top"><p class="table">4</p></td>
<td colspan="2" align="center" valign="top"><p class="table">(ask to user interactively)</p></td>
</tr>
</tbody>
</table>
</div>
</div>
<h2 id="_limitations">Limitations</h2>
<div class="sectionbody">
<h3 id="_socks5_authentication">SOCKS5 authentication</h3><div style="clear:left"></div>
<div class="paragraph"><p>Only NO-AUTH and USER/PASSWORD authentications are supported. GSSAPI
authentication (RFC 1961) and other draft authentications (CHAP, EAP,
MAF, etc.) is not supported.</p></div>
<h3 id="_http_authentication">HTTP authentication</h3><div style="clear:left"></div>
<div class="paragraph"><p>BASIC authentication is supported but DIGEST authentication is not.</p></div>
<h3 id="_switching_proxy_server_on_event">Switching proxy server on event</h3><div style="clear:left"></div>
<div class="paragraph"><p>There is no mechanism to switch proxy server regarding to PC
environment. This limitation might be bad news for mobile user. Since
I do not want to make this program complex, I do not want to support
although this feature is already requested. Please advice me if there
is good idea of detecting environment to swich and simple way to
specify conditioned directive of servers.</p></div>
<div class="paragraph"><p>One tricky workaround exists. It is replacing <tt>~/.ssh/config</tt> file by
script on ppp up/down.</p></div>
<div class="paragraph"><p>There&#8217;s another example of wrapper script (contributed by Darren
Tucker). This script costs executing ifconfig and grep to detect
current environment, but it works.  Note that you should modify
addresses if you use it.</p></div>
<div class="listingblock">
<div class="content">
<pre><tt>#!/bin/sh
## ~/bin/myconnect --- Proxy server switching wrapper

if ifconfig eth0 |grep "inet addr:192\.168\.1" &gt;/dev/null; then
        opts="-S 192.168.1.1:1080"
elif ifconfig eth0 |grep "inet addr:10\." &gt;/dev/null; then
        opts="-H 10.1.1.1:80"
else
        opts="-s"
fi
exec /usr/local/bin/connect $opts $@</tt></pre>
</div></div>
</div>
<h2 id="_tips">Tips</h2>
<div class="sectionbody">
<h3 id="_proxying_socket_connection">Proxying socket connection</h3><div style="clear:left"></div>
<div class="paragraph"><p>In usual, <tt>connect.c</tt> relays network connection to/from standard
input/output. By specifying -p option, however, <tt>connect.c</tt> relays local
network stream instead of standard input/output. With this option,
connect command waits connection from other program, then start
relaying between both network stream.</p></div>
<div class="paragraph"><p>This feature may be useful for the program which is hard to SOCKSify.</p></div>
<h3 id="_use_with_ssh_askpass_command">Use with ssh-askpass command</h3><div style="clear:left"></div>
<div class="paragraph"><p><tt>connect.c</tt> ask you password when authentication is required. If you
are using on tty/pty terminal, connect can input from terminal with
prompt. But you can also use ssh-askpass program to input password. If
you are graphical environment like X Window or MS Windows, and program
does not have tty/pty, and environment variable <tt>SSH_ASKPASS</tt> is
specified, then <tt>connect.c</tt> invoke command specified by environment
variable SSH_ASKPASS to input password. ssh-askpass program might be
installed if you are using OpenSSH on UNIX environment. On Windows
environment, pre-compiled binary is available from here.</p></div>
<div class="paragraph"><p>This feature is limited on window system environment.</p></div>
<div class="paragraph"><p>And also useful on Emacs on MS Windows (NT Emacs or Meadow). It is
hard to send passphrase to connect command (and also ssh) because
external command is invoked on hidden terminal and do I/O with this
terminal. Using ssh-askpass avoids this problem.</p></div>
<h3 id="_use_for_network_stream_of_emacs">Use for Network Stream of Emacs</h3><div style="clear:left"></div>
<div class="paragraph"><p>Although <tt>connect.c</tt> is made for OpenSSH, it is generic and independent
from OpenSSH. So we can use this for other purpose. For example, you
can use this command in Emacs to open network connection with remote
host over the firewall via SOCKS or HTTP proxy without SOCKSifying
Emacs itself.</p></div>
<div class="paragraph"><p>There is sample code:
<a href="http://bitbucket.org/gotoh/connect/src/tip/relay.el">http://bitbucket.org/gotoh/connect/src/tip/relay.el</a></p></div>
<div class="paragraph"><p>With this code, you can use <tt>relay-open-network-stream</tt> function instead
of <tt>open-network-stream</tt> to make network connection. See top comments of
the source for more detail.</p></div>
<h3 id="_remote_resolver">Remote resolver</h3><div style="clear:left"></div>
<div class="paragraph"><p>If you are SOCKS4 user on UNIX environment, you might want specify
nameserver to resolve remote hostname. You can do it specifying <tt>-R</tt>
option followed by IP address of resolver.</p></div>
<h3 id="_hopping_connection_via_ssh">Hopping Connection via SSH</h3><div style="clear:left"></div>
<div class="paragraph"><p>Conbination of ssh and connect command have more interesting
usage. Following command makes indirect connection to host2:port from
your current host via host1.</p></div>
<div class="listingblock">
<div class="content">
<pre><tt>$ ssh host1 connect host2 port</tt></pre>
</div></div>
<div class="paragraph"><p>This method is useful for the situations like:</p></div>
<div class="ulist"><ul>
<li>
<p>
You are outside of organizasion now, but you want to access an
  internal host barriered by firewall.
</p>
</li>
<li>
<p>
You want to use some service which is allowed only from some limited hosts.
</p>
</li>
</ul></div>
<div class="paragraph"><p>For example, I want to use local NetNews service in my office from
home. I cannot make NNTP session directly because NNTP host is
barriered by firewall. Fortunately, I have ssh account on internal
host and allowed using SOCKS5 on firewall from outside. So I use
following command to connect to NNTP service.</p></div>
<div class="listingblock">
<div class="content">
<pre><tt>$ ssh host1 connect news 119
200 news.my-office.com InterNetNews NNRP server INN 2.3.2 ready (posting ok).
quit
205 .
$</tt></pre>
</div></div>
<div class="paragraph"><p>By combinating hopping connection and relay.el, I can read NetNews
using <a href="http://www.gohome.org/wl/">Wanderlust</a> on Emacs at home.</p></div>
<div class="listingblock">
<div class="content">
<pre><tt>                        |
    External (internet) | Internal (office)
                        |
+------+           +----------+          +-------+           +-----------+
| HOME |           | firewall |          | host1 |           | NNTP host |
+------+           +----------+          +-------+           +-----------+
 emacs &lt;-------------- ssh ---------------&gt; sshd &lt;-- connect --&gt; nntpd
       &lt;-- connect --&gt; socksd &lt;-- SOCKS --&gt;</tt></pre>
</div></div>
<div class="paragraph"><p>As an advanced example, you can use SSH hopping as fetchmail&#8217;s plug-in
program to access via secure tunnel. This method requires that connect
program is insatalled on remote host. There&#8217;s example of .fetchmailrc
bellow. When fetchmail access to mail-server, you will login to remote
host using SSH then execute connect program on remote host to relay
conversation with pop server. Thus fetchmail can retrieve mails in
secure.</p></div>
<div class="listingblock">
<div class="content">
<pre><tt>poll mail-server
  protocol pop3
  plugin "ssh %h connect localhost %p"
  username "username"
  password "password"</tt></pre>
</div></div>
</div>
<h2 id="_break_the_more_restricted_wall">Break The More Restricted Wall</h2>
<div class="sectionbody">
<div class="paragraph"><p>If firewall does not provide SOCKS nor HTTPS other than port 443, you
cannot break the wall in usual way. But if you have you own host which
is accessible from internet, you can make ssh connection to your own
host by configuring sshd as waiting at port 443 instead of standard
22. By this, you can login to your own host via port 443. Once you
have logged-in to extenal home machine, you can execute connect as
second hop to make connection from your own host to final target host,
like this:</p></div>
<div class="listingblock">
<div class="content">
<pre><tt>internal$ cat ~/.ssh/config
Host home
    ProxyCommand connect -H firewall:8080 %h 443

Host server # internal
    ProxyCommand ssh home connect %h %p

internal$ ssh home
You are logged in to home!
home# exit
internal$ ssh server
You are logged in to server!
server# exit
internal$</tt></pre>
</div></div>
<div class="paragraph"><p>This way is similar to "Hopping connection via SSH" except configuring
outer sshd as waiting at port 443 (https). This means that you have a
capability to break the strongly restricted wall if you have own host
out side of the wall.</p></div>
<div class="listingblock">
<div class="content">
<pre><tt>                        |
      Internal (office) | External (internet)
                        |
+--------+         +----------+                 +------+          +--------+
| office |         | firewall |                 | home |          | server |
+--------+         +----------+                 +------+          +--------+
   &lt;------------------ ssh ---------------------&gt;sshd:443
    &lt;-- connect --&gt; http-proxy &lt;-- https:443 --&gt;                      any
                                                 connect &lt;-- tcp --&gt;  port</tt></pre>
</div></div>
<div class="admonitionblock">
<table><tr>
<td class="icon">
<div class="title">Note</div>
</td>
<td class="content">If you wanna use this, you should give up hosting https
      service at port 443 on you external host <em>home</em>.</td>
</tr></table>
</div>
</div>
<h2 id="_f_y_i">F.Y.I.</h2>
<div class="sectionbody">
<h3 id="_difference_between_socks_versions">Difference between SOCKS versions</h3><div style="clear:left"></div>
<div class="paragraph"><p>SOCKS version 4 is first popular implementation which is documented
<a href="http://www.socks.nec.com/protocol/socks4.protocol">here</a>. Since this
protocol provide IP address based requesting, client program should
resolve name of outer host by itself. Version 4a (documented
<a href="http://www.socks.nec.com/protocol/socks4a.protocol">here</a>) is
enhanced to allow request by hostname instead of IP address.</p></div>
<div class="paragraph"><p>SOCKS version 5 is re-designed protocol stands on experience of
version 4 and 4a. There is no compativility with previous
versions. Instead, there&#8217;s some improvement: IPv6 support, request by
hostname, UDP proxying, etc.</p></div>
<h3 id="_configuration_to_use_https">Configuration to use HTTPS</h3><div style="clear:left"></div>
<div class="paragraph"><p>Many http proxy servers implementation supports https CONNECT method
(SLL). You might add configuration to allow using https. For the
example of <a href="http://www.delegate.org/delegate/">DeleGate</a> (DeleGate is a
multi-purpose application level gateway, or a proxy server) , you
should add https to REMITTABLE parameter to allow HTTP-Proxy like
this:</p></div>
<div class="listingblock">
<div class="content">
<pre><tt>delegated -Pxxxx ...... REMITTABLE='+,https' ...</tt></pre>
</div></div>
<div class="paragraph"><p>For the case of Squid, you should allow target ports via https by ACL,
and so on.</p></div>
<h3 id="_socks5_servers">SOCKS5 Servers</h3><div style="clear:left"></div>
<div class="dlist"><dl>
<dt class="hdlist1">
<a href="http://www.socks.nec.com/refsoftware.html">NEC SOCKS Reference Implementation</a>
</dt>
<dd>
<p>
    Reference implementation of SOKCS server and library.
</p>
</dd>
<dt class="hdlist1">
<a href="http://www.inet.no/dante/index.html">Dante</a>
</dt>
<dd>
<p>
    Dante is free implementation of SOKCS server and library. Many
    enhancements and modulalized.
</p>
</dd>
<dt class="hdlist1">
<a href="http://www.delegate.org/delegate/">DeleGate</a>
</dt>
<dd>
<p>
    DeleGate is multi function proxy service provider. DeleGate 5.x.x
    or earlier can be SOCKS4 server, and 6.x.x can be SOCKS5 and
    SOCKS4 server. and 7.7.0 or later can be SOCKS5 and SOCKS4a
    server.
</p>
</dd>
</dl></div>
<h3 id="_specifications">Specifications</h3><div style="clear:left"></div>
<div class="dlist"><dl>
<dt class="hdlist1">
<a href="http://www.socks.nec.com/protocol/socks4.protocol">socks4.protocol.txt</a>
</dt>
<dd>
<p>
    SOCKS: A protocol for TCP proxy across firewalls
</p>
</dd>
<dt class="hdlist1">
<a href="http://www.socks.nec.com/protocol/socks4a.protocol">socks4a.protocol.txt</a>
</dt>
<dd>
<p>
    SOCKS 4A: A Simple Extension to SOCKS 4 Protocol
</p>
</dd>
<dt class="hdlist1">
<a href="http://www.socks.nec.com/rfc/rfc1928.txt">RFC 1928</a>
</dt>
<dd>
<p>
    SOCKS Protocol Version 5
</p>
</dd>
<dt class="hdlist1">
<a href="http://www.socks.nec.com/rfc/rfc1929.txt">RFC 1929</a>
</dt>
<dd>
<p>
    Username/Password Authentication for SOCKS V5
</p>
</dd>
<dt class="hdlist1">
<a href="http://www.ietf.org/rfc/rfc2616.txt">RFC 2616</a>
</dt>
<dd>
<p>
    Hypertext Transfer Protocol&#8201;&#8212;&#8201;HTTP/1.1
</p>
</dd>
<dt class="hdlist1">
<a href="http://www.ietf.org/rfc/rfc2617.txt">RFC 2617</a>
</dt>
<dd>
<p>
    HTTP Authentication: Basic and Digest Access Authentication
</p>
</dd>
</dl></div>
<h3 id="_related_links">Related Links</h3><div style="clear:left"></div>
<div class="ulist"><ul>
<li>
<p>
<a href="http://www.openssh.org/">OpenSSH Home</a>
</p>
</li>
<li>
<p>
<a href="http://www.ssh.com/">Proprietary SSH</a>
</p>
</li>
<li>
<p>
<a href="http://www.taiyo.co.jp/~gotoh/ssh/openssh-socks.html">Using OpenSSH through a SOCKS compatible PROXY on your LAN</a> (J. Grant)
</p>
</li>
</ul></div>
<h3 id="_similars">Similars</h3><div style="clear:left"></div>
<div class="dlist"><dl>
<dt class="hdlist1">
<a href="http://proxytunnel.sourceforge.net/">Proxy Tunnel</a>
</dt>
<dd>
<p>
Proxying command using https CONNECT.
</p>
</dd>
<dt class="hdlist1">
<a href="http://www.snurgle.org/~griffon/ssh-https-tunnel">stunnel</a>
</dt>
<dd>
<p>
Proxy through an https tunnel (Perl script)
</p>
</dd>
</dl></div>
</div>
</div>
<div id="footnotes"><hr /></div>
<div id="footer">
<div id="footer-text">
Last updated 2009-12-17 21:28:59 JST
</div>
</div>
</body>
</html>