Skip to content

Commit

Permalink
Merge pull request garygrossgarten#19 from garygrossgarten/resolve-us…
Browse files Browse the repository at this point in the history
…er-pw

Resolve user pw
  • Loading branch information
garygrossgarten authored Nov 21, 2020
2 parents 59f4f89 + e6fa90e commit 106e952
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 12 deletions.
7 changes: 7 additions & 0 deletions .github/workflows/ssh-example-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,13 @@ jobs:
username: garygrossgarten
password: ${{ secrets.PASSPHRASE }}
privateKey: ${{ secrets.PRIVATE_KEY}}
- name: User/Pw
uses: ./
with:
command: ls -a
host: ${{ secrets.HOST }}
username: garygrossgarten
password: ${{ secrets.PASSPHRASE }}
- name: This step should fail
uses: ./
with:
Expand Down
10 changes: 7 additions & 3 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11311,16 +11311,20 @@ function connect(host = 'localhost', username, port = 22, privateKey, password,
const ssh = new node_ssh_1.NodeSSH();
console.log(`Establishing a SSH connection to ${host}.`);
try {
yield ssh.connect({
const config = {
host: host,
port: port,
username: username,
password: password,
passphrase: passphrase,
privateKey: privateKey,
tryKeyboard: tryKeyboard,
onKeyboardInteractive: tryKeyboard ? keyboard_1.keyboardFunction(password) : null
});
};
if (privateKey) {
console.log('using provided private key');
config.privateKey = privateKey;
}
yield ssh.connect(config);
console.log(`🤝 Connected to ${host}.`);
}
catch (err) {
Expand Down
10 changes: 7 additions & 3 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,16 +56,20 @@ function connect(host = 'localhost', username, port = 22, privateKey, password,
const ssh = new node_ssh_1.NodeSSH();
console.log(`Establishing a SSH connection to ${host}.`);
try {
yield ssh.connect({
const config = {
host: host,
port: port,
username: username,
password: password,
passphrase: passphrase,
privateKey: privateKey,
tryKeyboard: tryKeyboard,
onKeyboardInteractive: tryKeyboard ? keyboard_1.keyboardFunction(password) : null
});
};
if (privateKey) {
console.log('using provided private key');
config.privateKey = privateKey;
}
yield ssh.connect(config);
console.log(`🤝 Connected to ${host}.`);
}
catch (err) {
Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@garygrossgarten/github-action-ssh",
"version": "0.6.1",
"version": "0.6.2",
"description": "Run commands on a remote server via SSH.",
"repository": {
"type": "git",
Expand Down
12 changes: 8 additions & 4 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as core from '@actions/core';
import {NodeSSH} from 'node-ssh';
import {Config, NodeSSH} from 'node-ssh';
import {keyboardFunction} from './keyboard';

async function run() {
Expand Down Expand Up @@ -43,16 +43,20 @@ async function connect(
console.log(`Establishing a SSH connection to ${host}.`);

try {
await ssh.connect({
const config: Config = {
host: host,
port: port,
username: username,
password: password,
passphrase: passphrase,
privateKey: privateKey,
tryKeyboard: tryKeyboard,
onKeyboardInteractive: tryKeyboard ? keyboardFunction(password) : null
});
};
if (privateKey) {
console.log('using provided private key');
config.privateKey = privateKey;
}
await ssh.connect(config);
console.log(`🤝 Connected to ${host}.`);
} catch (err) {
console.error(`⚠️ The GitHub Action couldn't connect to ${host}.`, err);
Expand Down

0 comments on commit 106e952

Please sign in to comment.