npm i -g ssh-access-manager
ssh-access-manager --help
Usage: server-man [options]
Options:
-V, --version output the version number
-a, --list-all List available servers and users
-c, --config [ ./servers.js ] File exports hashmap of { servername: [ "user@host", optionalPort ]}
-n, --server-name [ testserver ] Comma separated list of server names to operate
-l, --list List allowed users in all the servers
-g, --grant [ user1 ] Grant access to comma separated list of users
-r, --revoke [ user1 ] Revoke access of comma separated list of users
-s, --set-access [ user1 ] Set access to comma separated list of users only
-j, --json Print result as json object instead of table format
-U, --update [ ./acl.js ] set access on all servers as specified in acl.js
-h, --help display help for command
- create a file
<username>inside directory calledkeysand add any number of keys there. A user can have multiple ssh keys. - Eg: create a file
keys/jakeand add any number of keys in the that file. All these keys will be treated as Jake's key
- Create a file called
servers.jswhich should export an array of objects - Each object can have the following properties
host:hostname or IP addreess or entry defined in ssh configname:A name to indentify the server.port:Port number ( Optional )user:ssh user ( Optional )
Eg
module.exports = [
{
name: 'app1Dev',
host: '8.8.8.8',
},
{
name: 'app1Staging',
host: '8.8.8.9',
},
];- list currently loaded server names and usernames
npx ssh-access-manager -a
- list status of all servers.
npx ssh-access-manager -l
- grant access to username 'jake' on server called 'devserver'
npx ssh-access-manager -n devserver -g jake
- set access of server 'devserver' to user 'jake' only
npx ssh-access-manager -n devserver -s jake
- revoke access to username 'jake' on server called 'devserver'
npx ssh-access-manager -n devserver -r jake
- Dump curret Access-Control-List ( ACL ) for servers. ( Ie, simply dump output of
-lcommand as json )
npx ssh-access-manager -l -j
- Update server access from
acl.jsfile.
npx ssh-access-manager -U
We can create a acl.js file by simply dumping current state in all the servers.
npx ssh-access-manager -l -j >> acl.json
var server = new Server( [ 'devuser@8.8.8.8', 1122 ] );
// list the usernames in the server
server.listAccess(); // -> Promise( Array<String> )
server.grantAccess( 'hari' ); // -> Promise( Array<String> )
server.revokeAccess( 'hari' ); // -> Promise( Array<String> )
server.setAccess( 'hari' ); // -> Promise( Array<String> )