mirror of
https://github.com/Fabio286/antares.git
synced 2025-06-05 21:59:22 +02:00
feat: support to SSH private keys with passphrase, closes #118
This commit is contained in:
@ -30,7 +30,8 @@ export default connections => {
|
|||||||
username: conn.sshUser,
|
username: conn.sshUser,
|
||||||
password: conn.sshPass,
|
password: conn.sshPass,
|
||||||
port: conn.sshPort ? conn.sshPort : 22,
|
port: conn.sshPort ? conn.sshPort : 22,
|
||||||
identity: conn.sshKey
|
privateKey: conn.sshKey ? fs.readFileSync(conn.sshKey) : null,
|
||||||
|
passphrase: conn.sshPassphrase
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -85,7 +86,8 @@ export default connections => {
|
|||||||
username: conn.sshUser,
|
username: conn.sshUser,
|
||||||
password: conn.sshPass,
|
password: conn.sshPass,
|
||||||
port: conn.sshPort ? conn.sshPort : 22,
|
port: conn.sshPort ? conn.sshPort : 22,
|
||||||
identity: conn.sshKey
|
privateKey: conn.sshKey ? fs.readFileSync(conn.sshKey) : null,
|
||||||
|
passphrase: conn.sshPassphrase
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -16,6 +16,7 @@ export class AntaresCore {
|
|||||||
this._params = args.params;
|
this._params = args.params;
|
||||||
this._poolSize = args.poolSize || false;
|
this._poolSize = args.poolSize || false;
|
||||||
this._connection = null;
|
this._connection = null;
|
||||||
|
this._ssh = null;
|
||||||
this._logger = args.logger || console.log;
|
this._logger = args.logger || console.log;
|
||||||
|
|
||||||
this._queryDefaults = {
|
this._queryDefaults = {
|
||||||
|
@ -118,13 +118,19 @@ export class MySQLClient extends AntaresCore {
|
|||||||
if (this._params.ssl) dbConfig.ssl = { ...this._params.ssl };
|
if (this._params.ssl) dbConfig.ssl = { ...this._params.ssl };
|
||||||
|
|
||||||
if (this._params.ssh) {
|
if (this._params.ssh) {
|
||||||
this._ssh = new SSH2Promise({ ...this._params.ssh });
|
try {
|
||||||
|
this._ssh = new SSH2Promise({ ...this._params.ssh });
|
||||||
|
|
||||||
this._tunnel = await this._ssh.addTunnel({
|
const tunnel = await this._ssh.addTunnel({
|
||||||
remoteAddr: this._params.host,
|
remoteAddr: this._params.host,
|
||||||
remotePort: this._params.port
|
remotePort: this._params.port
|
||||||
});
|
});
|
||||||
dbConfig.port = this._tunnel.localPort;
|
dbConfig.port = tunnel.localPort;
|
||||||
|
}
|
||||||
|
catch (err) {
|
||||||
|
if (this._ssh) this._ssh.close();
|
||||||
|
throw err;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!this._poolSize)
|
if (!this._poolSize)
|
||||||
|
@ -65,13 +65,19 @@ export class PostgreSQLClient extends AntaresCore {
|
|||||||
if (this._params.ssl) dbConfig.ssl = { ...this._params.ssl };
|
if (this._params.ssl) dbConfig.ssl = { ...this._params.ssl };
|
||||||
|
|
||||||
if (this._params.ssh) {
|
if (this._params.ssh) {
|
||||||
this._ssh = new SSH2Promise({ ...this._params.ssh });
|
try {
|
||||||
|
this._ssh = new SSH2Promise({ ...this._params.ssh });
|
||||||
|
|
||||||
this._tunnel = await this._ssh.addTunnel({
|
const tunnel = await this._ssh.addTunnel({
|
||||||
remoteAddr: this._params.host,
|
remoteAddr: this._params.host,
|
||||||
remotePort: this._params.port
|
remotePort: this._params.port
|
||||||
});
|
});
|
||||||
dbConfig.port = this._tunnel.localPort;
|
dbConfig.port = tunnel.localPort;
|
||||||
|
}
|
||||||
|
catch (err) {
|
||||||
|
if (this._ssh) this._ssh.close();
|
||||||
|
throw err;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!this._poolSize) {
|
if (!this._poolSize) {
|
||||||
|
@ -309,6 +309,18 @@
|
|||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="form-group columns">
|
||||||
|
<div class="column col-4 col-sm-12">
|
||||||
|
<label class="form-label">{{ $t('word.passphrase') }}</label>
|
||||||
|
</div>
|
||||||
|
<div class="column col-8 col-sm-12">
|
||||||
|
<input
|
||||||
|
v-model="connection.sshPassphrase"
|
||||||
|
class="form-input"
|
||||||
|
type="password"
|
||||||
|
>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</fieldset>
|
</fieldset>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
@ -439,7 +451,7 @@ export default {
|
|||||||
try {
|
try {
|
||||||
const res = await Connection.makeTest(this.connection);
|
const res = await Connection.makeTest(this.connection);
|
||||||
if (res.status === 'error')
|
if (res.status === 'error')
|
||||||
this.addNotification({ status: 'error', message: res.response.message });
|
this.addNotification({ status: 'error', message: res.response.message || res.response.toString() });
|
||||||
else
|
else
|
||||||
this.addNotification({ status: 'success', message: this.$t('message.connectionSuccessfullyMade') });
|
this.addNotification({ status: 'success', message: this.$t('message.connectionSuccessfullyMade') });
|
||||||
}
|
}
|
||||||
@ -462,7 +474,7 @@ export default {
|
|||||||
else {
|
else {
|
||||||
const res = await Connection.makeTest(params);
|
const res = await Connection.makeTest(params);
|
||||||
if (res.status === 'error')
|
if (res.status === 'error')
|
||||||
this.addNotification({ status: 'error', message: res.response.message });
|
this.addNotification({ status: 'error', message: res.response.message || res.response.toString() });
|
||||||
else
|
else
|
||||||
this.addNotification({ status: 'success', message: this.$t('message.connectionSuccessfullyMade') });
|
this.addNotification({ status: 'success', message: this.$t('message.connectionSuccessfullyMade') });
|
||||||
}
|
}
|
||||||
|
@ -303,6 +303,18 @@
|
|||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="form-group columns">
|
||||||
|
<div class="column col-4 col-sm-12">
|
||||||
|
<label class="form-label">{{ $t('word.passphrase') }}</label>
|
||||||
|
</div>
|
||||||
|
<div class="column col-8 col-sm-12">
|
||||||
|
<input
|
||||||
|
v-model="localConnection.sshPassphrase"
|
||||||
|
class="form-input"
|
||||||
|
type="password"
|
||||||
|
>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</fieldset>
|
</fieldset>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
@ -414,7 +426,7 @@ export default {
|
|||||||
try {
|
try {
|
||||||
const res = await Connection.makeTest(this.localConnection);
|
const res = await Connection.makeTest(this.localConnection);
|
||||||
if (res.status === 'error')
|
if (res.status === 'error')
|
||||||
this.addNotification({ status: 'error', message: res.response.message });
|
this.addNotification({ status: 'error', message: res.response.message || res.response.toString() });
|
||||||
else
|
else
|
||||||
this.addNotification({ status: 'success', message: this.$t('message.connectionSuccessfullyMade') });
|
this.addNotification({ status: 'success', message: this.$t('message.connectionSuccessfullyMade') });
|
||||||
}
|
}
|
||||||
@ -437,7 +449,7 @@ export default {
|
|||||||
else {
|
else {
|
||||||
const res = await Connection.makeTest(params);
|
const res = await Connection.makeTest(params);
|
||||||
if (res.status === 'error')
|
if (res.status === 'error')
|
||||||
this.addNotification({ status: 'error', message: res.response.message });
|
this.addNotification({ status: 'error', message: res.response.message || res.response.toString() });
|
||||||
else
|
else
|
||||||
this.addNotification({ status: 'success', message: this.$t('message.connectionSuccessfullyMade') });
|
this.addNotification({ status: 'success', message: this.$t('message.connectionSuccessfullyMade') });
|
||||||
}
|
}
|
||||||
|
@ -119,7 +119,8 @@ module.exports = {
|
|||||||
routine: 'Routine',
|
routine: 'Routine',
|
||||||
new: 'New',
|
new: 'New',
|
||||||
history: 'History',
|
history: 'History',
|
||||||
select: 'Select'
|
select: 'Select',
|
||||||
|
passphrase: 'Passphrase'
|
||||||
},
|
},
|
||||||
message: {
|
message: {
|
||||||
appWelcome: 'Welcome to Antares SQL Client!',
|
appWelcome: 'Welcome to Antares SQL Client!',
|
||||||
|
Reference in New Issue
Block a user