开发者

Problem while using Netsieben SSH with System (scp ) command

I am facing some unique problem , not sure how to solve it . I am using the Netsiebin SSH C++ library for connecting with my server . It works perfectly well . I Connected to remote host using SSH2 protocol, with publickey authentication, sent come command to execute at the server too .

But the problem comes when I started using SCP or rsync "system( scp or rsync )in between .Its necessary for me to upload some files to server in between and then run Netseiben SSH function again to run that command file at server.But this never happen . Whenever I use some scp or rsync command and then execute some netseiben function it keeps on waiting and never returns .

Implementation sample:

  1. Initialize Netseiben

Ne7SftpSubsystem _sftp; ne7ssh *_ssh = new ne7ssh();

2.Connect with Key

channel1 = _ssh->connectWithKey ("serverAddress", 22, "userame", "pub key path");

3. Send command and read result

       _ssh->send ("ls\n", channel1))
       _ssh->waitFor (channel1, "$", 5)
       result = _ssh->read (channel1); //read result
  1. System function to put some file in server (Which i think is cause for all)

    system( "rsync /home/user/Makefile user@server:~"); system( "scp /home/user/file.tgz user@server:~/new");// this Executes

  2. Send come command to server (fails here ...This statement never executes)

    ssh->send ("mkdir Tester\n", channel1)

If I dont have the above "system" function to execute some command it works fine .

Is it something to do with Port number . Because at the开发者_StackOverflow社区 time of establishing connection I give port number 22 and if I am not wrong scp happens via port the same port which might cause problem . ot sure though . Have been setting with this for a day . Thanks for your help .

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜