Skip to content

Commit f2b2dc3

Browse files
committed
feat: support SSH passwords via sshpass
Refs #2302
1 parent aa49736 commit f2b2dc3

File tree

3 files changed

+95
-62
lines changed

3 files changed

+95
-62
lines changed

source/connections.lfm

Lines changed: 66 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,13 @@ object connform: Tconnform
1212
Constraints.MinHeight = 338
1313
Constraints.MinWidth = 550
1414
DesignTimePPI = 120
15+
ShowHint = True
1516
OnClose = FormClose
1617
OnCloseQuery = FormCloseQuery
1718
OnCreate = FormCreate
1819
OnDestroy = FormDestroy
1920
OnResize = FormResize
2021
OnShow = FormShow
21-
ShowHint = True
2222
object splitterMain: TSplitter
2323
Cursor = crSizeWE
2424
Left = 260
@@ -208,11 +208,11 @@ object connform: Tconnform
208208
ImageIndex = 75
209209
MaxLength = 0
210210
NumGlyphs = 1
211+
PasswordChar = #0
212+
TabOrder = 5
211213
OnButtonClick = editUsernameRightButtonClick
212214
OnChange = Modification
213215
OnExit = editTrim
214-
PasswordChar = #0
215-
TabOrder = 5
216216
end
217217
object editHost: TEditButton
218218
AnchorSideLeft.Side = asrBottom
@@ -229,11 +229,11 @@ object connform: Tconnform
229229
ImageIndex = 75
230230
MaxLength = 0
231231
NumGlyphs = 1
232+
PasswordChar = #0
233+
TabOrder = 2
232234
OnChange = editHostChange
233235
OnDblClick = editHostDblClick
234236
OnExit = editTrim
235-
PasswordChar = #0
236-
TabOrder = 2
237237
end
238238
object comboNetType: TComboBoxEx
239239
AnchorSideLeft.Side = asrBottom
@@ -249,9 +249,9 @@ object connform: Tconnform
249249
Images = MainForm.ImageListIcons8
250250
ItemHeight = 20
251251
ItemsEx = <>
252-
OnChange = comboNetTypeChange
253252
Style = csExDropDownList
254253
TabOrder = 0
254+
OnChange = comboNetTypeChange
255255
end
256256
object chkLoginPrompt: TCheckBox
257257
AnchorSideTop.Control = editHost
@@ -307,11 +307,11 @@ object connform: Tconnform
307307
ImageIndex = 75
308308
MaxLength = 0
309309
NumGlyphs = 1
310-
OnButtonClick = editDatabasesRightButtonClick
311-
OnChange = Modification
312310
PasswordChar = #0
313311
TabOrder = 9
314312
TextHint = 'Separated by semicolon'
313+
OnButtonClick = editDatabasesRightButtonClick
314+
OnChange = Modification
315315
end
316316
object comboLibrary: TComboBox
317317
AnchorSideLeft.Side = asrBottom
@@ -335,76 +335,76 @@ object connform: Tconnform
335335
ClientWidth = 648
336336
ImageIndex = 147
337337
object lblSSHLocalPort: TLabel
338-
AnchorSideTop.Control = editSSHPrivateKey
339-
AnchorSideTop.Side = asrBottom
338+
AnchorSideTop.Control = editSSHlocalport
339+
AnchorSideTop.Side = asrCenter
340340
Left = 4
341341
Height = 20
342-
Top = 240
342+
Top = 270
343343
Width = 70
344344
BorderSpacing.Around = 6
345345
Caption = 'Local port:'
346346
FocusControl = editSSHlocalport
347347
end
348348
object lblSSHUser: TLabel
349-
AnchorSideTop.Control = editSSHhost
350-
AnchorSideTop.Side = asrBottom
349+
AnchorSideTop.Control = editSSHUser
350+
AnchorSideTop.Side = asrCenter
351351
Left = 4
352352
Height = 20
353-
Top = 104
353+
Top = 108
354354
Width = 69
355355
BorderSpacing.Around = 6
356356
Caption = 'Username:'
357357
FocusControl = editSSHUser
358358
end
359359
object lblSSHPassword: TLabel
360-
AnchorSideTop.Control = editSSHUser
361-
AnchorSideTop.Side = asrBottom
360+
AnchorSideTop.Control = editSSHPassword
361+
AnchorSideTop.Side = asrCenter
362362
Left = 4
363363
Height = 20
364-
Top = 138
364+
Top = 142
365365
Width = 64
366366
BorderSpacing.Around = 6
367367
Caption = 'Password:'
368368
FocusControl = editSSHPassword
369369
end
370370
object lblSSHExe: TLabel
371-
AnchorSideTop.Control = chkSSHActive
372-
AnchorSideTop.Side = asrBottom
371+
AnchorSideTop.Control = comboSSHExe
372+
AnchorSideTop.Side = asrCenter
373373
Left = 4
374374
Height = 20
375-
Top = 36
375+
Top = 40
376376
Width = 106
377377
BorderSpacing.Around = 6
378378
Caption = 'SSH executable:'
379379
end
380380
object lblSSHhost: TLabel
381-
AnchorSideTop.Control = comboSSHExe
382-
AnchorSideTop.Side = asrBottom
381+
AnchorSideTop.Control = editSSHhost
382+
AnchorSideTop.Side = asrCenter
383383
Left = 4
384384
Height = 20
385-
Top = 70
385+
Top = 74
386386
Width = 108
387387
BorderSpacing.Around = 6
388388
Caption = 'SSH host + port:'
389389
FocusControl = editSSHhost
390390
end
391391
object lblSSHkeyfile: TLabel
392-
AnchorSideTop.Control = editSSHTimeout
393-
AnchorSideTop.Side = asrBottom
392+
AnchorSideTop.Control = editSSHPrivateKey
393+
AnchorSideTop.Side = asrCenter
394394
Left = 4
395395
Height = 20
396-
Top = 206
396+
Top = 236
397397
Width = 99
398398
BorderSpacing.Around = 6
399399
Caption = 'Private key file:'
400400
FocusControl = editSSHPrivateKey
401401
end
402402
object lblSSHTimeout: TLabel
403-
AnchorSideTop.Control = editSSHPassword
404-
AnchorSideTop.Side = asrBottom
403+
AnchorSideTop.Control = editSSHTimeout
404+
AnchorSideTop.Side = asrCenter
405405
Left = 4
406406
Height = 20
407-
Top = 172
407+
Top = 202
408408
Width = 86
409409
BorderSpacing.Around = 6
410410
Caption = 'SSH timeout:'
@@ -414,7 +414,7 @@ object connform: Tconnform
414414
AnchorSideTop.Side = asrBottom
415415
Left = 242
416416
Height = 28
417-
Top = 240
417+
Top = 266
418418
Width = 400
419419
Anchors = [akTop, akLeft, akRight]
420420
BorderSpacing.Around = 6
@@ -487,7 +487,7 @@ object connform: Tconnform
487487
AnchorSideTop.Side = asrBottom
488488
Left = 242
489489
Height = 28
490-
Top = 206
490+
Top = 232
491491
Width = 400
492492
Anchors = [akTop, akLeft, akRight]
493493
BorderSpacing.Around = 6
@@ -496,21 +496,21 @@ object connform: Tconnform
496496
ImageIndex = 51
497497
MaxLength = 0
498498
NumGlyphs = 1
499-
OnButtonClick = PickFile
500-
OnChange = Modification
501-
OnDblClick = PickFile
502-
OnExit = editTrim
503499
PasswordChar = #0
504500
TabOrder = 7
505501
Text = 'editSSHPrivateKey'
506502
TextHint = 'Private key / identify file'
503+
OnButtonClick = PickFile
504+
OnChange = Modification
505+
OnDblClick = PickFile
506+
OnExit = editTrim
507507
end
508508
object editSSHTimeout: TEdit
509-
AnchorSideTop.Control = editSSHPassword
509+
AnchorSideTop.Control = lblSshPassHint
510510
AnchorSideTop.Side = asrBottom
511511
Left = 242
512512
Height = 28
513-
Top = 172
513+
Top = 198
514514
Width = 75
515515
BorderSpacing.Around = 6
516516
NumbersOnly = True
@@ -544,6 +544,18 @@ object connform: Tconnform
544544
TabOrder = 0
545545
OnClick = Modification
546546
end
547+
object lblSshPassHint: TLabel
548+
AnchorSideLeft.Control = editSSHPassword
549+
AnchorSideTop.Control = editSSHPassword
550+
AnchorSideTop.Side = asrBottom
551+
Left = 248
552+
Height = 20
553+
Top = 172
554+
Width = 355
555+
BorderSpacing.Around = 6
556+
Caption = 'Make sure sshpass is available when using a password'
557+
Enabled = False
558+
end
547559
end
548560
object tabAdvanced: TTabSheet
549561
Caption = 'Advanced'
@@ -651,12 +663,12 @@ object connform: Tconnform
651663
ImageIndex = 51
652664
MaxLength = 0
653665
NumGlyphs = 1
666+
PasswordChar = #0
667+
TabOrder = 0
654668
OnButtonClick = PickFile
655669
OnChange = Modification
656670
OnDblClick = PickFile
657671
OnExit = editTrim
658-
PasswordChar = #0
659-
TabOrder = 0
660672
end
661673
object chkFullTableStatus: TCheckBox
662674
AnchorSideTop.Control = chkLocalTimeZone
@@ -713,8 +725,8 @@ object connform: Tconnform
713725
BorderSpacing.Around = 6
714726
DropDownCount = 16
715727
ItemHeight = 20
716-
OnChange = Modification
717728
TabOrder = 6
729+
OnChange = Modification
718730
end
719731
object editIgnoreDatabasePattern: TEdit
720732
AnchorSideTop.Control = ColorBoxBackgroundColor
@@ -757,10 +769,10 @@ object connform: Tconnform
757769
ImageIndex = 51
758770
MaxLength = 0
759771
NumGlyphs = 1
760-
OnButtonClick = PickFile
761-
OnChange = Modification
762772
PasswordChar = #0
763773
TabOrder = 8
774+
OnButtonClick = PickFile
775+
OnChange = Modification
764776
end
765777
object chkLogFileDml: TCheckBox
766778
AnchorSideTop.Control = chkLogFileDdl
@@ -874,13 +886,13 @@ object connform: Tconnform
874886
ImageIndex = 51
875887
MaxLength = 0
876888
NumGlyphs = 1
889+
PasswordChar = #0
890+
TabOrder = 3
891+
TextHint = 'Path to certificate file'
877892
OnButtonClick = PickFile
878893
OnChange = Modification
879894
OnDblClick = PickFile
880895
OnExit = editTrim
881-
PasswordChar = #0
882-
TabOrder = 3
883-
TextHint = 'Path to certificate file'
884896
end
885897
object editSSLCACertificate: TEditButton
886898
AnchorSideTop.Control = editSSLPrivateKey
@@ -896,13 +908,13 @@ object connform: Tconnform
896908
ImageIndex = 51
897909
MaxLength = 0
898910
NumGlyphs = 1
911+
PasswordChar = #0
912+
TabOrder = 2
913+
TextHint = 'Path to certificate authority file'
899914
OnButtonClick = PickFile
900915
OnChange = Modification
901916
OnDblClick = PickFile
902917
OnExit = editTrim
903-
PasswordChar = #0
904-
TabOrder = 2
905-
TextHint = 'Path to certificate authority file'
906918
end
907919
object editSSLPrivateKey: TEditButton
908920
AnchorSideTop.Control = chkWantSSL
@@ -918,13 +930,13 @@ object connform: Tconnform
918930
ImageIndex = 51
919931
MaxLength = 0
920932
NumGlyphs = 1
933+
PasswordChar = #0
934+
TabOrder = 1
935+
TextHint = 'Path to key file'
921936
OnButtonClick = PickFile
922937
OnChange = Modification
923938
OnDblClick = PickFile
924939
OnExit = editTrim
925-
PasswordChar = #0
926-
TabOrder = 1
927-
TextHint = 'Path to key file'
928940
end
929941
object comboSSLVerification: TComboBox
930942
AnchorSideTop.Control = editSSLcipher
@@ -1126,11 +1138,11 @@ object connform: Tconnform
11261138
ImageIndex = 193
11271139
MaxLength = 0
11281140
NumGlyphs = 1
1129-
OnButtonClick = editSearchRightButtonClick
1130-
OnChange = editSearchChange
11311141
PasswordChar = #0
11321142
TabOrder = 1
11331143
TextHint = 'Filter'
1144+
OnButtonClick = editSearchRightButtonClick
1145+
OnChange = editSearchChange
11341146
end
11351147
end
11361148
object pnlBottom: TPanel
@@ -1344,8 +1356,8 @@ object connform: Tconnform
13441356
object actFilter: TAction
13451357
Caption = 'Filter ...'
13461358
ImageIndex = 30
1347-
OnExecute = actFilterExecute
13481359
ShortCut = 16454
1360+
OnExecute = actFilterExecute
13491361
end
13501362
end
13511363
object timerEditFilterDelay: TTimer

source/connections.pas

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ Tconnform = class(TExtForm)
2525
btnSave: TSpeedButton;
2626
btnNew: TSpeedButton;
2727
btnDelete: TSpeedButton;
28+
lblSshPassHint: TLabel;
2829
pnlBottom: TPanel;
2930
popupSessions: TPopupMenu;
3031
menuSave: TMenuItem;
@@ -1627,6 +1628,8 @@ procedure Tconnform.ValidateControls;
16271628
editSSHUser.Enabled := Params.SSHActive;
16281629
lblSSHPassword.Enabled := Params.SSHActive;
16291630
editSSHPassword.Enabled := Params.SSHActive;
1631+
lblSshPassHint.Enabled := Params.SSHActive and (editSSHPassword.Text <> '');
1632+
lblSshPassHint.Visible := not Params.SshIsPlink;
16301633
lblSSHTimeout.Enabled := Params.SSHActive;
16311634
editSSHTimeout.Enabled := Params.SSHActive;
16321635
lblSSHkeyfile.Enabled := Params.SSHActive;

0 commit comments

Comments
 (0)