项目作者: arafathusayn

项目描述 :
Remotely lock/unlock your computer (Linux) using HTTP/JSON API, SSH Key & IP Whitelisting
高级语言: JavaScript
项目地址: git://github.com/arafathusayn/remote-box-locker.git
创建时间: 2019-01-14T17:01:27Z
项目社区:https://github.com/arafathusayn/remote-box-locker

开源协议:MIT License

下载


remote-box-locker

Remotely lock/unlock your computer (Linux) using HTTP/JSON, SSH Key & IP whitelisting

System Requirements

  • node.js and npm
  • SSH Private Key (a password must be set)
  • .env file for setting up required configurations

Install

  1. git clone https://github.com/arafathusayn/remote-box-locker.git && cd remote-box-locker && npm install

Configuration

Create a .env file in the remote-box-locker directory, then you can set these environment variables:

  1. SERVER_PORT=3333
  2. USERNAME=<your computer username>
  3. TRUST_PROXY=true or false
  4. IP_WHITELIST=<comma seperated IP addresses> eg. 192.168.0.100,192.168.0.101
  5. PRIVATE_KEY_PATH=/home/<USERNAME>/.ssh/id_rsa

Notes

  • USERNAME env variable is required.
  • If your computer network is behind a trustable proxy, set TRUST_PROXY=true so that IP_WHITELIST can work properly. Default: false.
  • IP_WHITELIST always includes localhost,127.0.0.1 as whitelisted
  • PRIVATE_KEY_PATH is your SSH private key path. It’s optional. Default: /home/<USERNAME>/.ssh/id_rsa

Running server

  1. node app.js

If you use pm2:

  1. pm2 start -f app.js

API Usage

Locking

To lock the computer running the server, send HTTP POST request to

  1. Endpoint: /lock
  2. eg. http://localhost:3333/lock

along with HTTP Header Content-Type: application/json and the JSON data in POST Body:

  1. {
  2. "password": "<Your SSH Private Key Password>"
  3. }

Unlocking

To unlock the computer running the server, send HTTP POST request to

  1. Endpoint: /unlock
  2. eg. http://localhost:3333/unlock

along with HTTP Header Content-Type: application/json and the JSON data in POST Body:

  1. {
  2. "password": "<Your SSH Private Key Password>"
  3. }