Blame examples/libsshpp.cpp

Packit Service 31306d
/*
Packit Service 31306d
Copyright 2010 Aris Adamantiadis
Packit Service 31306d
Packit Service 31306d
This file is part of the SSH Library
Packit Service 31306d
Packit Service 31306d
You are free to copy this file, modify it in any way, consider it being public
Packit Service 31306d
domain. This does not apply to the rest of the library though, but it is
Packit Service 31306d
allowed to cut-and-paste working code from this file to any license of
Packit Service 31306d
program.
Packit Service 31306d
*/
Packit Service 31306d
Packit Service 31306d
/* This file demonstrates the use of the C++ wrapper to libssh */
Packit Service 31306d
Packit Service 31306d
#include <iostream>
Packit Service 31306d
#include <string>
Packit Service 31306d
#include <libssh/libsshpp.hpp>
Packit Service 31306d
Packit Service 31306d
int main(int argc, const char **argv){
Packit Service 31306d
  ssh::Session session;
Packit Service 31306d
  try {
Packit Service 31306d
    if(argc>1)
Packit Service 31306d
      session.setOption(SSH_OPTIONS_HOST,argv[1]);
Packit Service 31306d
    else
Packit Service 31306d
      session.setOption(SSH_OPTIONS_HOST,"localhost");
Packit Service 31306d
    session.connect();
Packit Service 31306d
    session.userauthPublickeyAuto();
Packit Service 31306d
    session.disconnect();
Packit Service 31306d
  } catch (ssh::SshException e){
Packit Service 31306d
    std::cout << "Error during connection : ";
Packit Service 31306d
    std::cout << e.getError() << std::endl;
Packit Service 31306d
  }
Packit Service 31306d
  return 0;
Packit Service 31306d
}