The POCO C++ Libraries Blog


Filed under: News by peter at 12:30

I’m currently in the process of pocofying libssh so that it integrates nicely with the current networking library. Progress so far is good, secure copy and SSH terminal are already supported (SFTP will be pushed back for the moment, NetConf over SSH has more priority currently).

Take a look at the following examples to get a first impression of the interface and the use of the library. The first example uploads a file via SCP and then reads it back:

using namespace Poco::SSH;

DummyValidator val; //auto-accepts all servers, for testing only
Poco::Net::SocketAddress addr(SERVER, 22);
Poco::AutoPtr<SSHSession> ptrSes = new SSHSession(val, addr, USER, PWD);
Poco::File locFile(“dummy.file”);
Poco::Path remFile(“/tmp/dummy.file”);
std::ifstream in(“dummy.file”, std::ios::binary);
poco_assert (in);

// now write the file
SCPOutputStream out(*ptrSes, locFile, remFile);
Poco::StreamCopier::copyStream(in, out);
out << std::flush;

// read it back
SCPInputStream in(*ptrSes, remFile);
Poco::StreamCopier::copyStream(in, std::cout);
The second example opens a shell at the server and executes a command:

DummyValidator val;
Poco::Net::SocketAddress addr(SERVER, 22);
Poco::AutoPtr ptrSes = new SSHSession(val, addr, USER, PWD);
SSHTerminal term(*ptrSes);
SSHChannel channel = term.openShell();
SSHChannelOutputStream out(channel);
SSHChannelInputStream in(channel);
out << "ls -al\n";
out << std::flush;
// simplified: read only one line
std::string txt;
std::getline(in, txt);

  1. hum.., very nice. 🙂

    Comment by Alessandro Ungaro on July 31, 2007, 22:27

  2. Hi, I am not what libssh you are using but you may see some sftp functionality on

    Best regards,

    Comment by Peter Jansson on May 27, 2008, 18:44

  3. libssh2-017

    PocoSSH is currently in the sandbox and we do not have anyone working on it at the moment. Would you be interested in contributing?

    Comment by alex on May 27, 2008, 22:34

  4. hi ,
    PocoSSH in the sandbox doesn’t seems to be working fine.The blocking command execution call to remote machine over SSH is crasing/hanging.Is somebody working on it.????
    Can we know the POCO guidelines ,if I have to contribute for the same.

    Best Regards,

    Comment by sridhar on July 3, 2008, 07:25

  5. hi Sreedhar,
    currently nobody is working on PocoSSH but every help is more than welcome. Our coding guideline is available from

    For further questions, or if you have already something to commit, simply write me an email: peter dot schojer at appinf dot com

    Comment by peter on July 3, 2008, 08:07

RSS RSS feed for comments on this post. TrackBack URI

Leave a comment