Here is the limitations:
- No public key file uploaded to server (since this may be run at different target machine), this is just for an automatic testing program, so security is not a concern.
- It’s automatically program run background, so no user input.
- I do not want to use “expect” which require user to install.
- I have know the root user’s password.
So I wonder is that a lightweight expect tool or a ssh library I can easily use to do such work.
libssh http://www.libssh.org/ can help for a C project.
Using Perl, there is a module which can be used: Net::SSH (I use it for +/- the same kind of purposes)