在线文件编辑器

I am making online file editor which works by SSH. It can connect to another SSH machine, read textarea, and make a remote SSH command with $textarea . What command shall i use, so it will change file called server.settings to contents of $textarea? Or some script?

Thanks in advance.

So, solution i made was: I echo'ed result from SSH command to textarea

tail -n 2000000000000000000 /root/server.log

Then made, that python will write the content from textarea to requested file.

I agree with Mark B this sounds dangerous. It would be much safer to have a service running on the machine that has the file to be modified, but I will assume you thought of that and that it's not an option.

A slightly safer way of doing it would be to use scp or sftp instead of ssh, so there's a smaller chance of arbitrary commands being run on the machine with the file to edit. So you would

  1. scp the file from machine2 to machine1
  2. Read the contents and put it in the textarea of your web page
  3. User edits contents and clicks Save
  4. scp the file back to machine2

I use shellinabox and there is no need for any of this. It is dead easy to chroot jail any clients connecting, and using screen I can have multiplexed terminals and persistent sessions.

$0.02