mirror of
https://github.com/danielsogl/awesome-cordova-plugins.git
synced 2025-01-31 18:49:43 +08:00
feat(ssh-connect): add new plugin for ssh connection (#3169)
This commit is contained in:
parent
141f0e6e41
commit
d9ded4d164
74
src/@ionic-native/plugins/ssh-connect/index.ts
Normal file
74
src/@ionic-native/plugins/ssh-connect/index.ts
Normal file
@ -0,0 +1,74 @@
|
|||||||
|
import { Injectable } from '@angular/core';
|
||||||
|
import { Plugin, Cordova, IonicNativePlugin } from '@ionic-native/core';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @name SSH Connect
|
||||||
|
* @description
|
||||||
|
* Cordova plugin to make connections and execute commands through SSH
|
||||||
|
*
|
||||||
|
* @usage
|
||||||
|
* ```typescript
|
||||||
|
* import { SSHConnect } from '@ionic-native/ssh-connect/ngx';
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* constructor(private sshConnect: SSHConnect) { }
|
||||||
|
*
|
||||||
|
* ...
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* this.sshConnect.connect('user', 'password', 'host', port)
|
||||||
|
* .then(resp => console.log(resp))
|
||||||
|
* .catch(error => console.error(error));
|
||||||
|
*
|
||||||
|
* this.sshConnect.executeCommand('command')
|
||||||
|
* .then(resp => console.log(resp))
|
||||||
|
* .catch(error => console.error(error));
|
||||||
|
*
|
||||||
|
* this.sshConnect.disconnect()
|
||||||
|
* .then(resp => console.log(resp))
|
||||||
|
* .catch(error => console.error(error));
|
||||||
|
*
|
||||||
|
* ```
|
||||||
|
*/
|
||||||
|
@Plugin({
|
||||||
|
pluginName: 'SSHConnect',
|
||||||
|
plugin: 'cordova-plugin-ssh-connect',
|
||||||
|
pluginRef: 'cordova.plugins.sshConnect',
|
||||||
|
repo: 'https://github.com/JosePerez27/cordova-plugin-ssh-connect',
|
||||||
|
platforms: ['Android']
|
||||||
|
})
|
||||||
|
@Injectable()
|
||||||
|
export class SSHConnect extends IonicNativePlugin {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Establish a remote ssh connection
|
||||||
|
* @param {user} user The remote host user
|
||||||
|
* @param {password} password The remote host password
|
||||||
|
* @param {host} host The remote device to connect
|
||||||
|
* @param {port} port The SSH port for connection (usually port 22)
|
||||||
|
* @return {Promise<any>} Returns an promise that resolves with the success of the connection
|
||||||
|
*/
|
||||||
|
@Cordova()
|
||||||
|
connect(user: string, password: string, host: string, port: number): Promise<any> {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Execute a command on the remote host connected by ssh
|
||||||
|
* @param {command} command The command to execute
|
||||||
|
* @return {Promise<any>} Returns an promise that resolves with the printed text on the remote console
|
||||||
|
*/
|
||||||
|
@Cordova()
|
||||||
|
executeCommand(command: string): Promise<any> {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Disconnect the SSH session
|
||||||
|
* @return {Promise<any>} Returns an promise that resolves with the success of the disconnection
|
||||||
|
*/
|
||||||
|
@Cordova()
|
||||||
|
disconnect(): Promise<any> {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user