1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22# # kdc/kdc5_err.et # # Copyright 1990 by the Massachusetts Institute of Technology. # # Export of this software from the United States of America may # require a specific license from the United States Government. # It is the responsibility of any person or organization contemplating # export to obtain such a license before exporting. # # WITHIN THAT CONSTRAINT, permission to use, copy, modify, and # distribute this software and its documentation for any purpose and # without fee is hereby granted, provided that the above copyright # notice appear in all copies and that both that copyright notice and # this permission/* 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 * specifically, without C++ exceptions */ #include <iostream> #define SSH_NO_CPP_EXCEPTIONS #include <libssh/libsshpp.hpp> int main(int argc, const char **argv){ ssh::Session session,s2; int err; if(argc>1) err=session.setOption(SSH_OPTIONS_HOST,argv[1]); else err=session.setOption(SSH_OPTIONS_HOST,"localhost"); if(err==SSH_ERROR) goto error; err=session.connect(); if(err==SSH_ERROR) goto error; err=session.userauthAutopubkey(); if(err==SSH_ERROR) goto error; return 0; error: std::cout << "Error during connection : "; std::cout << session.getError() << std::endl; return 1; }