Chinaunix首页 | 论坛 | 博客
  • 博客访问: 2097412
  • 博文数量: 414
  • 博客积分: 10312
  • 博客等级: 上将
  • 技术积分: 4921
  • 用 户 组: 普通用户
  • 注册时间: 2007-10-31 01:49
文章分类

全部博文(414)

文章存档

2011年(1)

2010年(29)

2009年(82)

2008年(301)

2007年(1)

分类: C/C++

2008-04-07 03:33:48

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
#include
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 " 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
--
View this message in context:

Sent from the SSH (Secure Shell) mailing list archive at Nabble.com.
 
 
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 " 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] -
[1] -
[2] -
 
 
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.
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.
 
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 <> (there is a Perl
version as well).
--
Regards,
ASK
Mike,
  Did you every get a resolution to this problem?
  I am having the same issue using sftp and I did
want to use keys.
William
 
 
 
阅读(1166) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~