|
View:
New views
4 Messages
—
Rating Filter:
Alert me
|
|
|
Send SSH-Password over C-Program
by mainway
::
Rate this Message:
Reply (Restricted by the Administrator) | Reply to Author | View Threaded | Show Only this Message Hello @all!
I'd like to start a ssh-connection over a c-program. I've tried it with "pope". It looks like that: //CODE #include <iostream> #include <string> using namespace std; int main() { FILE *write_fp; char password[50]; char command[50]; sprintf(password, "thats_the_ssh_password"); sprintf(command, "date"); write_fp = popen("ssh -l root server", "w"); fwrite(password, sizeof(char), strlen(password), write_fp); fwrite(command, sizeof(char), strlen(command), write_fp); pclose(write_fp); } //CODE You see i try to: - start "ssh -l root server" - send the password to the "root@server's password: " prompt - send a command ("date") over SSH to the server. I've found out that SSH doesn't expect the password over the "normal-channel". Does anybody know if there is the possibility to insert the password into the "ssh -l root server"-command? That would solve the problem... Thank you! Best regards, Mike |
|
|
Re: Send SSH-Password over C-Program
by Steven Hollingsworth
::
Rate this Message:
Reply (Restricted by the Administrator) | Reply to Author | View Threaded | Show Only this Message On Thu, Oct 11, 2007 at 03:23:07PM -0700, mainway wrote:
>[snip code] > > You see i try to: > - start "ssh -l root server" > - send the password to the "root@server's password: " prompt > - send a command ("date") over SSH to the server. > > I've found out that SSH doesn't expect the password over the > "normal-channel". > Does anybody know if there is the possibility to insert the password into > the "ssh -l root server"-command? > That would solve the problem... Not sure about how to solve the programming problem. I have to ask, have you thought about using a key with no passphrase[0]? I'm assuming you want to use this for automation. ssh -l root -i ~/.ssh/id_rsa "date" If not there are other open source programs out there [1] that do something similar as far as passing things to ssh. Also, I know expect [2] can pass arguments such as passwords to ssh as well. HTH, ~ stevo [0] - http://pkeck.myweb.uga.edu/ssh/ [1] - http://clusterssh.wiki.sourceforge.net/Main+Page [2] - http://rootprompt.org/article.php3?article=9187 |
|
|
Re: Send SSH-Password over C-Program
by Jeremy C. Reed
::
Rate this Message:
Reply (Restricted by the Administrator) | Reply to Author | View Threaded | Show Only this Message On Thu, 11 Oct 2007, mainway wrote:
> Does anybody know if there is the possibility to insert the password into > the "ssh -l root server"-command? > That would solve the problem... Most setup password-less keys for that. But I patched OpenSSH client in May to allow a user to set a password in their ssh configuration. See http://marc.info/?l=secure-shell&m=117995272708037&w=2 It is useful if you don't have control of the server itself. Anyone have thoughts on this? I have been using it since May. |
|
|
Re: Send SSH-Password over C-Program
by Alexander Klimov
::
Rate this Message:
Reply (Restricted by the Administrator) | Reply to Author | View Threaded | Show Only this Message On Thu, 11 Oct 2007, mainway wrote:
> I've found out that SSH doesn't expect the password over the > "normal-channel". This is a feature :-). The simplest option is to use a key file with empty password (man ssh-keygen). > Does anybody know if there is the possibility to insert the password into > the "ssh -l root server"-command? > That would solve the problem... You need a pseudo-terminal to fool ssh: the straightforward way is to use expect <http://expect.nist.gov/FAQ.html#q1> (there is a Perl version as well). -- Regards, ASK |
| Free embeddable forum powered by Nabble | Forum Help |