简体   繁体   中英

How to run CLI app (preferably Node) when user connects to server via SSH

If I wanted to run a CLI app whereby users connecting to my server would SSH to the box and be able to run commands, how would I go about doing that?

Is there a way of tying the SSH connection to a commander.js app for example?

All examples I can find are for commands being entered locally on the box and rely on the user entering .

I just want the user to have an interactive shell with a prompt where commands can be entered directly without any app name.

If there is any reference documentation for this type of setup that would be very helpful.

Thanks

If you wanted to restrict the user to a specific command and they are using private keys for authentication, you could use a line like this in /home/user/.ssh/authorized_keys :

command="node foo.js",no-port-forwarding,no-x11-forwarding,no-agent-forwarding ssh-rsa ....

Then when they connect and start a session, node foo.js will automatically execute no matter what program they try to start.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM