For example, I want to run:
ssh root@127.0.0.1 -p 2222
in C (via system) command. But right after I run that, it asks for input:
root@127.0.0.1's password:
Then I’m expected to type in the password. How can I do this in C code? Could I please get some code on how I could simulate key presses? Or is there a better way to do this?
there is a beautiful command expect
This is a common used tool. If you need only for a ssh, you’d better look at other posts for generating a key