Skip to content

Commit 67bab62

Browse files
committed
v0.3 + Re-creating SSH keys (ssh-keyscan)
1 parent 620ef38 commit 67bab62

File tree

7 files changed

+27
-18
lines changed

7 files changed

+27
-18
lines changed

sshuttle-gui/backup/sshuttle_gui.lps

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
<Filename Value="sshuttle_gui.lpr"/>
4040
<IsPartOfProject Value="True"/>
4141
<EditorIndex Value="-1"/>
42-
<UsageCount Value="39"/>
42+
<UsageCount Value="40"/>
4343
</Unit>
4444
<Unit>
4545
<Filename Value="unit1.pas"/>
@@ -49,9 +49,7 @@
4949
<ResourceBaseClass Value="Form"/>
5050
<UnitName Value="Unit1"/>
5151
<IsVisibleTab Value="True"/>
52-
<TopLine Value="183"/>
53-
<CursorPos X="8" Y="159"/>
54-
<UsageCount Value="39"/>
52+
<UsageCount Value="40"/>
5553
<Loaded Value="True"/>
5654
<LoadedDesigner Value="True"/>
5755
</Unit>
@@ -60,9 +58,8 @@
6058
<IsPartOfProject Value="True"/>
6159
<UnitName Value="PingTRD"/>
6260
<EditorIndex Value="1"/>
63-
<TopLine Value="54"/>
64-
<CursorPos Y="76"/>
65-
<UsageCount Value="35"/>
61+
<CursorPos X="15"/>
62+
<UsageCount Value="36"/>
6663
<Loaded Value="True"/>
6764
</Unit>
6865
<Unit>

sshuttle-gui/backup/unit1.pas

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -157,10 +157,17 @@ procedure TMainForm.StartBtnClick(Sender: TObject);
157157
Pars: string;
158158
S: TStringList;
159159
begin
160+
//Форматируем содержимое полей
161+
UserEdit.Text := Trim(UserEdit.Text);
162+
PasswordEdit.Text := Trim(PasswordEdit.Text);
163+
ServerEdit.Text := Trim(ServerEdit.Text);
164+
PortEdit.Text := Trim(PortEdit.Text);
165+
160166
//Проверка на пустоту
161-
if (Trim(UserEdit.Text) = '') or (Trim(PasswordEdit.Text) = '') or
162-
(Trim(ServerEdit.Text) = '') or (Trim(PortEdit.Text) = '') then Exit;
167+
if (UserEdit.Text = '') or (PasswordEdit.Text = '') or
168+
(ServerEdit.Text = '') or (PortEdit.Text = '') then Exit;
163169

170+
//Сохранение параметров
164171
IniPropStorage1.Save;
165172

166173
//Дополнительные параметры
@@ -183,10 +190,10 @@ procedure TMainForm.StartBtnClick(Sender: TObject);
183190
S.Add('#!/bin/bash');
184191
S.Add('');
185192

186-
S.Add('# Пересоздание ключей в /root/.ssh/known_hosts (пароль мог измениться)');
193+
S.Add('# Пересоздать ключи в /root/.ssh/known_hosts (параметры подключения могли измениться)');
187194

188195
//Очистка прежних ключей (мог измениться пароль или хост)
189-
S.Add('sed -i "/^' + Trim(ServerEDit.Text) + '/d" /root/.ssh/known_hosts');
196+
S.Add('sed -i "/^' + ServerEDit.Text + '/d" /root/.ssh/known_hosts');
190197
S.Add('');
191198

192199
//Пересоздать ключи для хоста (пароль мог измениться) + отмена зависших sshpass и очистка NAT
@@ -196,17 +203,16 @@ procedure TMainForm.StartBtnClick(Sender: TObject);
196203
Trim(PortEdit.Text) + ' exit 0'); }
197204

198205
S.Add('pidof sshpass && killall sshpass; iptables -t nat -F');
199-
S.Add('ssh-keyscan -p ' + Trim(PortEdit.Text) + ' ' +
200-
Trim(ServerEDit.Text) + ' >> /root/.ssh/known_hosts');
206+
S.Add('ssh-keyscan -p ' + PortEdit.Text + ' ' + ServerEDit.Text +
207+
' >> /root/.ssh/known_hosts');
201208

202209
S.Add('');
203210

204211
S.Add('# Запуск vpn');
205212
S.Add('[[ "$?" -eq "0" ]] && \');
206-
S.Add('sshpass -p "' + Trim(PasswordEdit.Text) + '" sshuttle --dns --remote ' +
207-
Trim(UserEdit.Text) + '@' + Trim(ServerEDit.Text) + ':' +
208-
Trim(PortEdit.Text) + ' -x ' + Trim(ServerEDit.Text) + ':' +
209-
Trim(PortEdit.Text) + ' 0/0 ' + Trim(Pars));
213+
S.Add('sshpass -p "' + PasswordEdit.Text + '" sshuttle --dns --remote ' +
214+
UserEdit.Text + '@' + ServerEDit.Text + ':' + PortEdit.Text +
215+
' -x ' + ServerEDit.Text + ':' + PortEdit.Text + ' 0/0 ' + Trim(Pars));
210216

211217
S.Add('exit 0;');
212218

@@ -220,5 +226,4 @@ procedure TMainForm.StartBtnClick(Sender: TObject);
220226
end;
221227
end;
222228

223-
224229
end.
272 Bytes
Binary file not shown.
0 Bytes
Binary file not shown.

sshuttle-gui/sshuttle_gui

0 Bytes
Binary file not shown.

sshuttle-gui/sshuttle_gui.lps

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,9 @@
4949
<ResourceBaseClass Value="Form"/>
5050
<UnitName Value="Unit1"/>
5151
<IsVisibleTab Value="True"/>
52+
<TopLine Value="196"/>
53+
<CursorPos X="13" Y="217"/>
54+
<ComponentState Value="1"/>
5255
<UsageCount Value="40"/>
5356
<Loaded Value="True"/>
5457
<LoadedDesigner Value="True"/>

sshuttle-gui/unit1.pas

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,10 @@ procedure TMainForm.StartBtnClick(Sender: TObject);
214214
UserEdit.Text + '@' + ServerEDit.Text + ':' + PortEdit.Text +
215215
' -x ' + ServerEDit.Text + ':' + PortEdit.Text + ' 0/0 ' + Trim(Pars));
216216

217+
S.Add('');
218+
219+
S.Add('iptables -t nat -F');
220+
217221
S.Add('exit 0;');
218222

219223
S.SaveToFile('/etc/sshuttle-gui/connect.sh');

0 commit comments

Comments
 (0)