/* * Copyright (C), 2000-2002 by Contributors to the monit codebase. * All Rights Reserved. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as * published by the Free Software Foundation; either version 2 of the * License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software Foundation, * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include #include #ifdef HAVE_STRING_H #include #endif #include "protocol.h" /** * A simple 'SSH protocol version exchange' implemetation based on * RFC (http://www.openssh.com/txt/draft-ietf-secsh-transport-14.txt) * * @author Igor Homyakov, * * @version \$Id: ssh.c,v 1.1 2002/11/25 17:00:38 hauk Exp $ * * @file */ int check_ssh(Port_T p) { char buf[STRLEN]; if ( port_recv(p, buf, sizeof(buf), 0) <= 0 ) { log("SSH: error receiving identification string -- %s\n", STRERROR); return FALSE; } chomp(buf); if (strncmp(buf, "SSH-", 4) != 0 ) { log("SSH: protocol error %s\n", buf); return FALSE; } /* send identification string back to server */ if ( port_send(p, buf, strlen(buf), 0) <= 0 ) { log("SSH: error sending identification string -- %s\n", STRERROR); return FALSE; } return TRUE; }