42 lines
1.0 KiB
JavaScript
42 lines
1.0 KiB
JavaScript
#!/usr/bin/env node
|
|
import Ssh from '../src/ssh'
|
|
import to from 'await-to-js'
|
|
import logger from '@uci/logger'
|
|
import yargs from 'yargs'
|
|
|
|
|
|
console.log(process.argv)
|
|
let arg = yargs
|
|
.alias('c','config')
|
|
.argv
|
|
|
|
;
|
|
(async () => {
|
|
const log = logger({ repo: 'remote-code', bin:'./bin/ssh.js', class:'Ssh', file:'src/ssh.js', id: 'binary' })
|
|
const ssh = new Ssh()
|
|
console.log('config file', arg)
|
|
await ssh.configure(arg.c ? arg.c : null) // default config
|
|
log.info(`making connection to ${ssh.opts.host}`)
|
|
let [err] = await to(ssh.connect())
|
|
if (err) {
|
|
log.info({err:err, msg:'unable to connect'})
|
|
return err
|
|
}
|
|
// let cmd = arg._.join(' ')
|
|
// console.log(cmd)
|
|
// let [err2,res] = await to(ssh.exec(cmd))
|
|
// if (err2) {
|
|
// log.info({err:err2, command:cmd, msg:'error running command aborting'})
|
|
// return
|
|
// }
|
|
// ssh.close()
|
|
// return res
|
|
|
|
let res = await ssh.shell({cli:true})
|
|
console.log('ALL DONE', res.command, res.cmds, )
|
|
|
|
|
|
})().catch(err => {
|
|
console.error('FATAL: Failed to Connecct to Remote!\n',err)
|
|
})
|