aboutsummaryrefslogtreecommitdiff
path: root/examples/libsshpp.cpp
blob: 0be88639b6b1faeb9c4a6be4faeb0a4967da28f6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
/*
Copyright 2010 Aris Adamantiadis

This file is part of the SSH Library

You are free to copy this file, modify it in any way, consider it being public
domain. This does not apply to the rest of the library though, but it is
allowed to cut-and-paste working code from this file to any license of
program.
*/

/* This file demonstrates the use of the C++ wrapper to libssh */

#include <iostream>
#include <libssh/libsshpp.hpp>

int main(int argc, const char **argv){
  ssh::Session session,s2;
  try {
    if(argc>1)
      session.setOption(SSH_OPTIONS_HOST,argv[1]);
    else
      session.setOption(SSH_OPTIONS_HOST,"localhost");
    session.connect();
    session.userauthAutopubkey();
  } catch (ssh::SshException e){
    std::cout << "Error during connection : ";
    std::cout << e.getError() << std::endl;
  }
  //s2=session;
  return 0;
}