From libssh2-devel-bounces@cool.haxx.se  Fri Jan  4 21:44:46 2019
Return-Path: <libssh2-devel-bounces@cool.haxx.se>
Received: from www.haxx.se (mail [127.0.0.1])
	by giant.haxx.se (8.15.2/8.15.2/Debian-4) with ESMTP id x04Ki9G6030497;
	Fri, 4 Jan 2019 21:44:36 +0100
Received: from gproxy8-pub.mail.unifiedlayer.com
 (gproxy8-pub.mail.unifiedlayer.com [67.222.33.93])
 by giant.haxx.se (8.15.2/8.15.2/Debian-4) with ESMTPS id x04Ki66n030310
 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT)
 for <libssh2-devel@cool.haxx.se>; Fri, 4 Jan 2019 21:44:07 +0100
Received: from cmgw10.unifiedlayer.com (unknown [10.9.0.10])
 by gproxy8.mail.unifiedlayer.com (Postfix) with ESMTP id 0818A1AE9BE
 for <libssh2-devel@cool.haxx.se>; Fri,  4 Jan 2019 13:39:05 -0700 (MST)
Received: from just14.justhost.com ([173.254.28.14]) by cmsmtp with ESMTP
 id fWFEgYLOWuj2ofWFEgmRgS; Fri, 04 Jan 2019 13:39:05 -0700
X-Authority-Reason: nr=8
Received: from 162-236-189-84.lightspeed.irvnca.sbcglobal.net
 ([162.236.189.84]:61851 helo=Office)
 by just14.justhost.com with esmtpsa (TLSv1:AES128-SHA:128)
 (Exim 4.91) (envelope-from <william@schuylerhouse.com>)
 id 1gfWFE-002VUu-Ga
 for libssh2-devel@cool.haxx.se; Fri, 04 Jan 2019 13:39:04 -0700
Message-ID: <AC4C79CF711446509A6FACFA10B9E2B2@Office>
From: "William Shipley" <william@schuylerhouse.com>
To: <libssh2-devel@cool.haxx.se>
Subject: sftp upload file path
Date: Fri, 4 Jan 2019 12:38:54 -0800
MIME-Version: 1.0
X-Priority: 3
X-MSMail-Priority: Normal
X-Mailer: Microsoft Windows Mail 6.0.6002.18197
X-MimeOLE: Produced By Microsoft MimeOLE V6.0.6002.19728
X-AntiAbuse: This header was added to track abuse,
 please include it with any abuse report
X-AntiAbuse: Primary Hostname - just14.justhost.com
X-AntiAbuse: Original Domain - cool.haxx.se
X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12]
X-AntiAbuse: Sender Address Domain - schuylerhouse.com
X-BWhitelist: no
X-Source-IP: 162.236.189.84
X-Source-L: No
X-Exim-ID: 1gfWFE-002VUu-Ga
X-Source: 
X-Source-Args: 
X-Source-Dir: 
X-Source-Sender: 162-236-189-84.lightspeed.irvnca.sbcglobal.net (Office)
 [162.236.189.84]:61851
X-Source-Auth: william@schuylerhouse.com
X-Email-Count: 39
X-Source-Cap: c2NodXlsZTY7c2NodXlsZTY7anVzdDE0Lmp1c3Rob3N0LmNvbQ==
X-Local-Domain: yes
X-BeenThere: libssh2-devel@cool.haxx.se
X-Mailman-Version: 2.1.22
Precedence: list
List-Id: libssh2 development <libssh2-devel.cool.haxx.se>
List-Unsubscribe: <https://cool.haxx.se/cgi-bin/mailman/options/libssh2-devel>, 
 <mailto:libssh2-devel-request@cool.haxx.se?subject=unsubscribe>
List-Archive: <http://cool.haxx.se/pipermail/libssh2-devel/>
List-Post: <mailto:libssh2-devel@cool.haxx.se>
List-Help: <mailto:libssh2-devel-request@cool.haxx.se?subject=help>
List-Subscribe: <https://cool.haxx.se/cgi-bin/mailman/listinfo/libssh2-devel>, 
 <mailto:libssh2-devel-request@cool.haxx.se?subject=subscribe>
Reply-To: libssh2 development <libssh2-devel@cool.haxx.se>
Content-Type: multipart/mixed; boundary="===============1805774731=="
Errors-To: libssh2-devel-bounces@cool.haxx.se
Sender: "libssh2-devel" <libssh2-devel-bounces@cool.haxx.se>

This is a multi-part message in MIME format.

--===============1805774731==
Content-Type: multipart/alternative;
	boundary="----=_NextPart_000_D580_01D4A42A.73DEA5E0"

This is a multi-part message in MIME format.

------=_NextPart_000_D580_01D4A42A.73DEA5E0
Content-Type: text/plain;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

I'm a newbie on a steep learning curve with SFTP in general. I am trying =
to implement libssh2 SFTP file upload to a CrushFTP server. Working with =
a slightly edited version of the sftp_write.c example, I find that if I =
call libssh2_sftp_open() with the path "newdir/file.txt" and the =
directory newdir exists in my FTP server's root, then I will get the =
file uploaded just fine.

If newdir does not exist, libssh2_sftp_open() function still succeeds =
and gives me a handle and a 0 libssh2_sftp_last_error() value, but when =
I call libssh2_sftp_write, I get an error -31 (ERROR_SFTP_PROTOCOL) on =
the function with status 4 (LIBSSH2_FX_FAILURE) as the =
libssh2_sftp_last_error(). No file is created.

I'm surprised that libssh2_sftp_open() apparently works but I cannot =
write to the file. Is there something else I should have checked?

What is the best practice approach for uploading a path with =
sub-directories that may not exist?

William Shipley
Schuyler House

------=_NextPart_000_D580_01D4A42A.73DEA5E0
Content-Type: text/html;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META content=3D"text/html; charset=3Diso-8859-1" =
http-equiv=3DContent-Type>
<META name=3DGENERATOR content=3D"MSHTML 9.00.8112.16872">
<STYLE></STYLE>
</HEAD>
<BODY bgColor=3D#ffffff>
<DIV>
<DIV>I'm a newbie on a steep learning curve with SFTP in general. I am =
trying to=20
implement libssh2 SFTP file upload to a CrushFTP server. Working with a =
slightly=20
edited version of the sftp_write.c example, I find that if I call=20
libssh2_sftp_open() with the path "newdir/file.txt" and the directory =
newdir=20
exists in my FTP server's root, then I will get the file uploaded just=20
fine.</DIV>
<DIV>&nbsp;</DIV>
<DIV></DIV>
<DIV>If newdir does not exist, libssh2_sftp_open() function still =
succeeds and=20
gives me a handle and a 0 libssh2_sftp_last_error() value, but when I =
call=20
libssh2_sftp_write, I get an error -31 (ERROR_SFTP_PROTOCOL) on the =
function=20
with status 4 (LIBSSH2_FX_FAILURE) as the libssh2_sftp_last_error(). No =
file is=20
created.</DIV>
<DIV>&nbsp;</DIV>
<DIV></DIV>
<DIV>I'm surprised that libssh2_sftp_open() apparently works but I =
cannot write=20
to the file. Is there something else I should have checked?<BR><BR>What =
is the=20
best practice approach for uploading a path with sub-directories that =
may not=20
exist?</DIV>
<DIV>&nbsp;</DIV>
<DIV></DIV>
<DIV>William Shipley</DIV>
<DIV>Schuyler House<BR></DIV></DIV></BODY></HTML>

------=_NextPart_000_D580_01D4A42A.73DEA5E0--


--===============1805774731==
Content-Type: text/plain; charset="utf-8"
MIME-Version: 1.0
Content-Transfer-Encoding: base64
Content-Disposition: inline

X19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX18KbGlic3NoMi1k
ZXZlbCBodHRwczovL2Nvb2wuaGF4eC5zZS9jZ2ktYmluL21haWxtYW4vbGlzdGluZm8vbGlic3No
Mi1kZXZlbAo=

--===============1805774731==--

From libssh2-devel-bounces@cool.haxx.se  Mon Jan  7 17:31:37 2019
Return-Path: <libssh2-devel-bounces@cool.haxx.se>
Received: from www.haxx.se (mail [127.0.0.1])
	by giant.haxx.se (8.15.2/8.15.2/Debian-4) with ESMTP id x07GUuwR008662;
	Mon, 7 Jan 2019 17:31:25 +0100
Received: from foo.stuge.se (foo.stuge.se [212.116.89.98])
 by giant.haxx.se (8.15.2/8.15.2/Debian-4) with ESMTPS id x07GUs3k008584
 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT)
 for <libssh2-devel@cool.haxx.se>; Mon, 7 Jan 2019 17:30:54 +0100
Received: (qmail 26638 invoked by uid 1000); 7 Jan 2019 16:30:49 -0000
Message-ID: <20190107163049.26637.qmail@stuge.se>
Date: Mon, 7 Jan 2019 16:30:49 +0000
From: Peter Stuge <peter@stuge.se>
To: libssh2-devel@cool.haxx.se
Subject: Re: sftp upload file path
References: <AC4C79CF711446509A6FACFA10B9E2B2@Office>
MIME-Version: 1.0
Content-Disposition: inline
In-Reply-To: <AC4C79CF711446509A6FACFA10B9E2B2@Office>
X-BeenThere: libssh2-devel@cool.haxx.se
X-Mailman-Version: 2.1.22
Precedence: list
List-Id: libssh2 development <libssh2-devel.cool.haxx.se>
List-Unsubscribe: <https://cool.haxx.se/cgi-bin/mailman/options/libssh2-devel>, 
 <mailto:libssh2-devel-request@cool.haxx.se?subject=unsubscribe>
List-Archive: <http://cool.haxx.se/pipermail/libssh2-devel/>
List-Post: <mailto:libssh2-devel@cool.haxx.se>
List-Help: <mailto:libssh2-devel-request@cool.haxx.se?subject=help>
List-Subscribe: <https://cool.haxx.se/cgi-bin/mailman/listinfo/libssh2-devel>, 
 <mailto:libssh2-devel-request@cool.haxx.se?subject=subscribe>
Reply-To: libssh2 development <libssh2-devel@cool.haxx.se>
Content-Type: text/plain; charset="utf-8"
Errors-To: libssh2-devel-bounces@cool.haxx.se
Sender: "libssh2-devel" <libssh2-devel-bounces@cool.haxx.se>
Content-Transfer-Encoding: 8bit
X-MIME-Autoconverted: from base64 to 8bit by giant.haxx.se id x07GUuwR008662

William Shipley wrote:
> What is the best practice approach for uploading a path with
> sub-directories that may not exist?

I'd suggest using libssh2_sftp_mkdir() to try to create the
directory, ignoring errors, then optionally _stat() to validate
permissions and _chmod() to correct them, finally _open() the file.

You'll have to handle one directory at a time. There is no -p.


//Peter
_______________________________________________
libssh2-devel https://cool.haxx.se/cgi-bin/mailman/listinfo/libssh2-devel

From libssh2-devel-bounces@cool.haxx.se  Tue Jan  8 08:12:30 2019
Return-Path: <libssh2-devel-bounces@cool.haxx.se>
Received: from www.haxx.se (mail [127.0.0.1])
	by giant.haxx.se (8.15.2/8.15.2/Debian-4) with ESMTP id x087BumS009375;
	Tue, 8 Jan 2019 08:12:20 +0100
Received: from mail-oi1-x244.google.com (mail-oi1-x244.google.com
 [IPv6:2607:f8b0:4864:20:0:0:0:244])
 by giant.haxx.se (8.15.2/8.15.2/Debian-4) with ESMTPS id x087Brs0009343
 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NOT)
 for <libssh2-devel@cool.haxx.se>; Tue, 8 Jan 2019 08:11:54 +0100
Received: by mail-oi1-x244.google.com with SMTP id x202so2489583oif.13
 for <libssh2-devel@cool.haxx.se>; Mon, 07 Jan 2019 23:11:54 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=llamas-org.20150623.gappssmtp.com; s=20150623;
 h=mime-version:from:date:message-id:subject:to;
 bh=WD33kzZP580MAb32Xisd3j2m4GJlSFKeRJF3Rd6bwaQ=;
 b=WGBU198GB82rWfaRVmNNgBayMWWMidpmVJZ4W5t87QBi2cCvWZcQhC11yucyaWCdz6
 i60+Wnt3kerUCuI5dtXr3KqnqesKhGCS1vE/2u/qTQtaVISJ1q8XBdy9P9fEyhMfd1EB
 SMmA8ki8RlZLd/e8pxRF05MQMTSpuZjZomAdYzOBiWk/9Yh3TiRC1HDUXHXoA5SjsUEn
 G9s+tbtKFDlXAcZcZnsPPFdBW3zHKT9uOKjNsg26AVdzbjfPmwB/Vg044DplrqUM5c50
 e/GvBegJycAoNjHRWiKZzJJU5MKw1p00BZyROXnyPw+AtwrhcWyCTrpFycqMt92tKWDW
 abMg==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20161025;
 h=x-gm-message-state:mime-version:from:date:message-id:subject:to;
 bh=WD33kzZP580MAb32Xisd3j2m4GJlSFKeRJF3Rd6bwaQ=;
 b=k/ybCkQ/DnEZcF7rIahsfsL3N7Fj91oi2Ehuafvclpt8/Oc8Y3dl7ikxMFZfJj9B0g
 gTltMNKWClY2+aFh733qFkEcE0Wfi1D5djsDIOzdjS/VdRpI5GmFmiiKFFsk69fWl6nf
 4vFN1BUXAI8a7hpXwzdqOLIe5gs4vclgvf3YJGniYiUY8c04nMysjscdX9rt9d5Ag3F6
 AMFbBh4TfrpaBMX3x8eL//Nw/zuwwFrhCbo/gMpWZiXfTxhRUN4t4lwiWCQv4mZZDcbE
 A1+Ns7+UlIMCL5MsNpkO5PCYaWqOnO20z3Z4tjmjM78POFConqFL5Tbm6X9wqdWj49wr
 Hj2w==
X-Gm-Message-State: AJcUukdw5c/vx54Rkk51XQHNEU5NA/9/H3CQpOczBA/DfEKFpRWi29ib
 MChV7JIE57VTRjwg8lH7bRWA8h2IukzKye6QoVNcMRX8
X-Google-Smtp-Source: ALg8bN76s1gRXZbxXyrhe/gGoFneacxy5EKosLo4o4ZXB/Z6wVsS+esus+unEalXR6bL/W71EfYQGrhhvI13nHciPDs=
X-Received: by 2002:aca:3dc5:: with SMTP id k188mr453812oia.108.1546931508170; 
 Mon, 07 Jan 2019 23:11:48 -0800 (PST)
MIME-Version: 1.0
From: George Nachman <gnachman@llamas.org>
Date: Mon, 7 Jan 2019 23:11:37 -0800
Message-ID: <CAB5Rqo=Q3PeVRcrJRa9rj-EY4Bo0VFB8ZjNTp-Jt5gVD-zJ_Sg@mail.gmail.com>
Subject: To quote or not to quote
To: libssh2-devel@cool.haxx.se
X-BeenThere: libssh2-devel@cool.haxx.se
X-Mailman-Version: 2.1.22
Precedence: list
List-Id: libssh2 development <libssh2-devel.cool.haxx.se>
List-Unsubscribe: <https://cool.haxx.se/cgi-bin/mailman/options/libssh2-devel>, 
 <mailto:libssh2-devel-request@cool.haxx.se?subject=unsubscribe>
List-Archive: <http://cool.haxx.se/pipermail/libssh2-devel/>
List-Post: <mailto:libssh2-devel@cool.haxx.se>
List-Help: <mailto:libssh2-devel-request@cool.haxx.se?subject=help>
List-Subscribe: <https://cool.haxx.se/cgi-bin/mailman/listinfo/libssh2-devel>, 
 <mailto:libssh2-devel-request@cool.haxx.se?subject=subscribe>
Reply-To: libssh2 development <libssh2-devel@cool.haxx.se>
Content-Type: multipart/mixed; boundary="===============0152331698=="
Errors-To: libssh2-devel-bounces@cool.haxx.se
Sender: "libssh2-devel" <libssh2-devel-bounces@cool.haxx.se>

--===============0152331698==
Content-Type: multipart/alternative; boundary="0000000000000957a3057eed0f32"

--0000000000000957a3057eed0f32
Content-Type: text/plain; charset="UTF-8"

I received an issue report that a user was unable to scp using my
application (which uses libssh2). He was connecting to the ssh server that
ships with macOS 10.13. The openSSH command line client worked. The
difference is whether the file name is quoted.

libssh2 sends:

scp -f '~/test.txt`

while openSSH sends:

scp -v -f ~/test.txt

libbsh2 log snippet:
https://gist.github.com/gnachman/352da57d455cb0943f5e06607511bda8

I thought I'd read the scp spec to see who's wrong but it seems there isn't
one :)

Does anyone know the history with the quotes? Is this a buggy server?

--0000000000000957a3057eed0f32
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><div dir=3D"ltr"><div dir=3D"ltr">I received an issue repo=
rt that a user was unable to scp using my application (which uses libssh2).=
 He was connecting to the ssh server that ships with macOS 10.13. The openS=
SH command line client worked. The difference is whether the file name is q=
uoted.<div><br></div><div>libssh2 sends:</div><div><br></div><div>scp -f &#=
39;~/test.txt`</div><div><br></div><div>while openSSH sends:</div><div><br>=
</div><div>scp -v -f ~/test.txt<br></div><div><br></div><div>libbsh2 log sn=
ippet:</div><div><a href=3D"https://gist.github.com/gnachman/352da57d455cb0=
943f5e06607511bda8">https://gist.github.com/gnachman/352da57d455cb0943f5e06=
607511bda8</a><br></div><div><br></div><div>I thought I&#39;d read the scp =
spec to see who&#39;s wrong but it seems there isn&#39;t one :)</div><div><=
br></div><div>Does anyone know the history with the quotes? Is this a buggy=
 server?</div></div></div></div>

--0000000000000957a3057eed0f32--

--===============0152331698==
Content-Type: text/plain; charset="utf-8"
MIME-Version: 1.0
Content-Transfer-Encoding: base64
Content-Disposition: inline

X19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX18KbGlic3NoMi1k
ZXZlbCBodHRwczovL2Nvb2wuaGF4eC5zZS9jZ2ktYmluL21haWxtYW4vbGlzdGluZm8vbGlic3No
Mi1kZXZlbAo=

--===============0152331698==--

From libssh2-devel-bounces@cool.haxx.se  Wed Jan  9 13:18:09 2019
Return-Path: <libssh2-devel-bounces@cool.haxx.se>
Received: from www.haxx.se (mail [127.0.0.1])
	by giant.haxx.se (8.15.2/8.15.2/Debian-4) with ESMTP id x09CHSKW007977;
	Wed, 9 Jan 2019 13:17:54 +0100
Received: from mail-ot1-x32b.google.com (mail-ot1-x32b.google.com
 [IPv6:2607:f8b0:4864:20:0:0:0:32b])
 by giant.haxx.se (8.15.2/8.15.2/Debian-4) with ESMTPS id x09CHQoU007913
 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NOT)
 for <libssh2-devel@cool.haxx.se>; Wed, 9 Jan 2019 13:17:27 +0100
Received: by mail-ot1-x32b.google.com with SMTP id 32so6451707ota.12
 for <libssh2-devel@cool.haxx.se>; Wed, 09 Jan 2019 04:17:28 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025;
 h=mime-version:from:date:message-id:subject:to;
 bh=cUlZ0bCR27QPYW7aDaxO4t9AxefWQBLpUcJNbDe+9fU=;
 b=fBNwtJja/M5dNmsMXnOof2t2LOoVcA5T0SQ+WVzcAHHVAi1Xi7nYlJyowVuYR/2tum
 jvb5a8vPsZ2c/EljaCxBtjNItPPZhVQRf107Rc5/NDfdXc8Vcm4+lvO6kRT9UAtuDVmI
 DMyqr1JJbjNIKfSmuqPXN2GVvny+EV7AwBUwWWqNgoDAJmLJN+K4LfQQo8bsW4YFmAvJ
 ZNDWZ2QwoZ+BJ4FYk82w/5TeFHX5LcE9N0v0gKkpx+6GuI2iqK4jgpoIFwbJWoIX6oMk
 FjixV/hR1nx5JI278jBtcO+G5BgG+I2k/xkcgrarmNMM3XXJnJsEJcF6emHoBPz95l83
 elew==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20161025;
 h=x-gm-message-state:mime-version:from:date:message-id:subject:to;
 bh=cUlZ0bCR27QPYW7aDaxO4t9AxefWQBLpUcJNbDe+9fU=;
 b=nLAaqdMyrpJK/OZ8DGLGUrCMUnXkocV9czQ7GJxgvHJ2WUp+WITTs4B7bES/1fgDv3
 x2CwtSZG+ZcdX2zKiiXDsrV0mwtSxeZyTWlqPsKzp9ZIVq31v0qYuZuDtopFCwZEo6W1
 tnYzMBTOfjX85J1GGTA2Z7zygZESEFSs43LaHrjVveoX6Hl+R3rDZV5oRiRybsWmlHyo
 MChYSVGjac3a8FzU1DGwHJEBtEFI2XrCXRvVX+ubiiVdfxlAX+Ati5Qq4YQpYSDoqWJD
 A/YK5q96aERbxQm0fRfDKmCg3f+jDJLSE1Q0TcSKvUnA5Dd8PFNu6J7LUZs0DnkQQH/0
 XsRg==
X-Gm-Message-State: AJcUukdFXleeyJWlyRMXrMRWkP8slp/Psjb/Ci1Tm4KjgFwf+bE4KpR3
 nYVx16Z9Uf/YZiblz17X7lwJPkucmtoqdAAl/VleBPyyy3g=
X-Google-Smtp-Source: ALg8bN6PVes5vYiTQn0QdI9ODiNW/Vxd6gZ4wLZSZK35J5XH4f2oeO3kIHqtffCtHuaLwXhnW087EwIP/EhK80O4aqY=
X-Received: by 2002:a9d:2926:: with SMTP id d35mr3762080otb.355.1547036241789; 
 Wed, 09 Jan 2019 04:17:21 -0800 (PST)
MIME-Version: 1.0
From: Richa Mehta <richa21089@gmail.com>
Date: Wed, 9 Jan 2019 17:47:10 +0530
Message-ID: <CACodhSEeDcLCRKpAFDs0HSce=q96F8DkFnQ3LOgTuEyxTy-4Ow@mail.gmail.com>
Subject: LIBSSH2_CHANNEL struct can be shared between the threads in c++??
To: libssh2-devel@cool.haxx.se
X-BeenThere: libssh2-devel@cool.haxx.se
X-Mailman-Version: 2.1.22
Precedence: list
List-Id: libssh2 development <libssh2-devel.cool.haxx.se>
List-Unsubscribe: <https://cool.haxx.se/cgi-bin/mailman/options/libssh2-devel>, 
 <mailto:libssh2-devel-request@cool.haxx.se?subject=unsubscribe>
List-Archive: <http://cool.haxx.se/pipermail/libssh2-devel/>
List-Post: <mailto:libssh2-devel@cool.haxx.se>
List-Help: <mailto:libssh2-devel-request@cool.haxx.se?subject=help>
List-Subscribe: <https://cool.haxx.se/cgi-bin/mailman/listinfo/libssh2-devel>, 
 <mailto:libssh2-devel-request@cool.haxx.se?subject=subscribe>
Reply-To: libssh2 development <libssh2-devel@cool.haxx.se>
Content-Type: multipart/mixed; boundary="===============1439911331=="
Errors-To: libssh2-devel-bounces@cool.haxx.se
Sender: "libssh2-devel" <libssh2-devel-bounces@cool.haxx.se>

--===============1439911331==
Content-Type: multipart/alternative; boundary="000000000000a58724057f057148"

--000000000000a58724057f057148
Content-Type: text/plain; charset="UTF-8"

Hi,

I want to share the ssh session and channels between the threads but as per
the introduction for thread safety, it is written there not to share
handles between threads so is it safe to share the ssh channels between
threads in C++??

Thanks,
Richa

--000000000000a58724057f057148
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">Hi,<div><br></div><div><span style=3D"color:rgb(36,41,46);=
font-family:-apple-system,BlinkMacSystemFont,&quot;Segoe UI&quot;,Helvetica=
,Arial,sans-serif,&quot;Apple Color Emoji&quot;,&quot;Segoe UI Emoji&quot;,=
&quot;Segoe UI Symbol&quot;;font-size:14px">I want to share the ssh session=
 and channels between the threads but as per the introduction for thread sa=
fety, it is written there not to share handles between threads so is it saf=
e to share the ssh channels between threads in C++??</span>=C2=A0</div><div=
><br></div><div>Thanks,</div><div>Richa</div><div>=C2=A0<br></div></div>

--000000000000a58724057f057148--

--===============1439911331==
Content-Type: text/plain; charset="utf-8"
MIME-Version: 1.0
Content-Transfer-Encoding: base64
Content-Disposition: inline

X19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX18KbGlic3NoMi1k
ZXZlbCBodHRwczovL2Nvb2wuaGF4eC5zZS9jZ2ktYmluL21haWxtYW4vbGlzdGluZm8vbGlic3No
Mi1kZXZlbAo=

--===============1439911331==--

From libssh2-devel-bounces@cool.haxx.se  Sun Jan 13 21:32:23 2019
Return-Path: <libssh2-devel-bounces@cool.haxx.se>
Received: from www.haxx.se (mail [127.0.0.1])
	by giant.haxx.se (8.15.2/8.15.2/Debian-4) with ESMTP id x0DKViSP031965;
	Sun, 13 Jan 2019 21:32:10 +0100
Received: from gproxy8-pub.mail.unifiedlayer.com
 (gproxy8-pub.mail.unifiedlayer.com [67.222.33.93])
 by giant.haxx.se (8.15.2/8.15.2/Debian-4) with ESMTPS id x0DKVf1s031910
 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT)
 for <libssh2-devel@cool.haxx.se>; Sun, 13 Jan 2019 21:31:42 +0100
Received: from cmgw14.unifiedlayer.com (unknown [10.9.0.14])
 by gproxy8.mail.unifiedlayer.com (Postfix) with ESMTP id 1CB891ACC70
 for <libssh2-devel@cool.haxx.se>; Sun, 13 Jan 2019 13:20:26 -0700 (MST)
Received: from just14.justhost.com ([173.254.28.14]) by cmsmtp with ESMTP
 id imF7gWr3kqU7OimF7gUiTs; Sun, 13 Jan 2019 13:20:26 -0700
X-Authority-Reason: nr=8
Received: from 162-236-189-84.lightspeed.irvnca.sbcglobal.net
 ([162.236.189.84]:61281 helo=Office)
 by just14.justhost.com with esmtpsa (TLSv1:AES128-SHA:128)
 (Exim 4.91) (envelope-from <william@schuylerhouse.com>)
 id 1gimF7-002vWh-Gn
 for libssh2-devel@cool.haxx.se; Sun, 13 Jan 2019 13:20:25 -0700
Message-ID: <AC5C840701F5474CB07DCE8F15ADAEE7@Office>
From: "William Shipley" <william@schuylerhouse.com>
To: <libssh2-devel@cool.haxx.se>
Subject: Using libssh2 for SFTP client, unexpected FD_READ
Date: Sun, 13 Jan 2019 12:20:08 -0800
MIME-Version: 1.0
X-Priority: 3
X-MSMail-Priority: Normal
X-Mailer: Microsoft Windows Mail 6.0.6002.18197
X-MimeOLE: Produced By Microsoft MimeOLE V6.0.6002.19728
X-AntiAbuse: This header was added to track abuse,
 please include it with any abuse report
X-AntiAbuse: Primary Hostname - just14.justhost.com
X-AntiAbuse: Original Domain - cool.haxx.se
X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12]
X-AntiAbuse: Sender Address Domain - schuylerhouse.com
X-BWhitelist: no
X-Source-IP: 162.236.189.84
X-Source-L: No
X-Exim-ID: 1gimF7-002vWh-Gn
X-Source: 
X-Source-Args: 
X-Source-Dir: 
X-Source-Sender: 162-236-189-84.lightspeed.irvnca.sbcglobal.net (Office)
 [162.236.189.84]:61281
X-Source-Auth: william@schuylerhouse.com
X-Email-Count: 11
X-Source-Cap: c2NodXlsZTY7c2NodXlsZTY7anVzdDE0Lmp1c3Rob3N0LmNvbQ==
X-Local-Domain: yes
X-BeenThere: libssh2-devel@cool.haxx.se
X-Mailman-Version: 2.1.22
Precedence: list
List-Id: libssh2 development <libssh2-devel.cool.haxx.se>
List-Unsubscribe: <https://cool.haxx.se/cgi-bin/mailman/options/libssh2-devel>, 
 <mailto:libssh2-devel-request@cool.haxx.se?subject=unsubscribe>
List-Archive: <http://cool.haxx.se/pipermail/libssh2-devel/>
List-Post: <mailto:libssh2-devel@cool.haxx.se>
List-Help: <mailto:libssh2-devel-request@cool.haxx.se?subject=help>
List-Subscribe: <https://cool.haxx.se/cgi-bin/mailman/listinfo/libssh2-devel>, 
 <mailto:libssh2-devel-request@cool.haxx.se?subject=subscribe>
Reply-To: libssh2 development <libssh2-devel@cool.haxx.se>
Content-Type: multipart/mixed; boundary="===============0800603619=="
Errors-To: libssh2-devel-bounces@cool.haxx.se
Sender: "libssh2-devel" <libssh2-devel-bounces@cool.haxx.se>

This is a multi-part message in MIME format.

--===============0800603619==
Content-Type: multipart/alternative;
	boundary="----=_NextPart_000_F0FD_01D4AB3A.529E5CB0"

This is a multi-part message in MIME format.

------=_NextPart_000_F0FD_01D4AB3A.529E5CB0
Content-Type: text/plain;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

I'm new to libssh2, SSH, and SFTP, It's working well for me and my =
client code is functioning. I am connected to a CrushFTP server and am =
noticing that when sitting idle, periodically (about 30 seconds) I am =
getting an FD_READ on my socket without having made a request. I suspect =
that this is probably the server sending a "keep alive" =
(SSH_MSG_IGNORE?).

I don't think I'm supposed to try to read and process this myself, but I =
can't see an obvious function in libssh2 to call to process it. 
------=_NextPart_000_F0FD_01D4AB3A.529E5CB0
Content-Type: text/html;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META content=3D"text/html; charset=3Diso-8859-1" =
http-equiv=3DContent-Type>
<META name=3DGENERATOR content=3D"MSHTML 9.00.8112.16872">
<STYLE></STYLE>
</HEAD>
<BODY bgColor=3D#ffffff>
<DIV>I'm new to libssh2, SSH, and SFTP, It's working well for me and my =
client=20
code&nbsp;is functioning. I am connected to a CrushFTP server and am =
noticing=20
that when sitting idle,&nbsp;periodically (about 30 seconds) I am =
getting an=20
FD_READ on my socket without having made a request. I suspect that this =
is=20
probably the server sending&nbsp;a "keep alive" =
(SSH_MSG_IGNORE?).<BR><BR>I=20
don't think I'm supposed to try to read and process this myself, but=20
I&nbsp;can't see an obvious function in&nbsp;libssh2 to call to=20
process&nbsp;it.&nbsp;</DIV></BODY></HTML>

------=_NextPart_000_F0FD_01D4AB3A.529E5CB0--


--===============0800603619==
Content-Type: text/plain; charset="utf-8"
MIME-Version: 1.0
Content-Transfer-Encoding: base64
Content-Disposition: inline

X19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX18KbGlic3NoMi1k
ZXZlbCBodHRwczovL2Nvb2wuaGF4eC5zZS9jZ2ktYmluL21haWxtYW4vbGlzdGluZm8vbGlic3No
Mi1kZXZlbAo=

--===============0800603619==--

From libssh2-devel-bounces@cool.haxx.se  Thu Jan 17 23:33:48 2019
Return-Path: <libssh2-devel-bounces@cool.haxx.se>
Received: from www.haxx.se (mail [127.0.0.1])
	by giant.haxx.se (8.15.2/8.15.2/Debian-4) with ESMTP id x0HMXALe004358;
	Thu, 17 Jan 2019 23:33:37 +0100
Received: from 954919-app2.systemsdesignusa.com
 (954919-app2.systemsdesignusa.com [72.3.203.202])
 by giant.haxx.se (8.15.2/8.15.2/Debian-4) with ESMTPS id x0HMX8oR004336
 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT)
 for <libssh2-devel@cool.haxx.se>; Thu, 17 Jan 2019 23:33:09 +0100
Received: from localhost (localhost [127.0.0.1])
 by 954919-app2.systemsdesignusa.com (Postfix) with ESMTP id 9C8A222600FF
 for <libssh2-devel@cool.haxx.se>; Thu, 17 Jan 2019 16:33:04 -0600 (CST)
Received: from 954919-app2.systemsdesignusa.com ([127.0.0.1])
 by localhost (954919-app2.systemsdesignusa.com [127.0.0.1]) (amavisd-new,
 port 10032)
 with ESMTP id qQFi2djEFTrC for <libssh2-devel@cool.haxx.se>;
 Thu, 17 Jan 2019 16:33:04 -0600 (CST)
Received: from localhost (localhost [127.0.0.1])
 by 954919-app2.systemsdesignusa.com (Postfix) with ESMTP id 40F092260113
 for <libssh2-devel@cool.haxx.se>; Thu, 17 Jan 2019 16:33:04 -0600 (CST)
X-Virus-Scanned: amavisd-new at systemsdesignusa.com
Received: from 954919-app2.systemsdesignusa.com ([127.0.0.1])
 by localhost (954919-app2.systemsdesignusa.com [127.0.0.1]) (amavisd-new,
 port 10026)
 with ESMTP id 9Gcmek5Lb8pp for <libssh2-devel@cool.haxx.se>;
 Thu, 17 Jan 2019 16:33:04 -0600 (CST)
Received: from 954919-app2.systemsdesignusa.com
 (954919-app2.systemsdesignusa.com [172.24.16.202])
 by 954919-app2.systemsdesignusa.com (Postfix) with ESMTP id 2D13A22600FF
 for <libssh2-devel@cool.haxx.se>; Thu, 17 Jan 2019 16:33:04 -0600 (CST)
Date: Thu, 17 Jan 2019 16:33:04 -0600 (CST)
From: "Kevin R. Bulgrien" <kevinb@systemsdesignusa.com>
To: libssh2-devel@cool.haxx.se
Message-ID: <786246453.7.1547764378188.JavaMail.KevinB@CSDI-LAP-KEVINB>
In-Reply-To: <237102017.0.1547762525936.JavaMail.KevinB@CSDI-LAP-KEVINB>
Subject: Building libssh2 1.2.4 through 1.8.0 on host type i686-pc-sco3.2v5.0.7
MIME-Version: 1.0
X-Originating-IP: [172.24.16.202]
X-Mailer: Zimbra 8.8.10_GA_3713 (Zimbra Desktop/7.3.1_13063_Windows)
Thread-Index: oTBK0CbFqJ/wW2GqZQNk58HHZm7SRw==
Thread-Topic: Building libssh2 1.2.4 through 1.8.0 on host type
 i686-pc-sco3.2v5.0.7
X-BeenThere: libssh2-devel@cool.haxx.se
X-Mailman-Version: 2.1.22
Precedence: list
List-Id: libssh2 development <libssh2-devel.cool.haxx.se>
List-Unsubscribe: <https://cool.haxx.se/cgi-bin/mailman/options/libssh2-devel>, 
 <mailto:libssh2-devel-request@cool.haxx.se?subject=unsubscribe>
List-Archive: <http://cool.haxx.se/pipermail/libssh2-devel/>
List-Post: <mailto:libssh2-devel@cool.haxx.se>
List-Help: <mailto:libssh2-devel-request@cool.haxx.se?subject=help>
List-Subscribe: <https://cool.haxx.se/cgi-bin/mailman/listinfo/libssh2-devel>, 
 <mailto:libssh2-devel-request@cool.haxx.se?subject=subscribe>
Reply-To: libssh2 development <libssh2-devel@cool.haxx.se>
Content-Type: text/plain; charset="utf-8"
Errors-To: libssh2-devel-bounces@cool.haxx.se
Sender: "libssh2-devel" <libssh2-devel-bounces@cool.haxx.se>
Content-Transfer-Encoding: 8bit
X-MIME-Autoconverted: from base64 to 8bit by giant.haxx.se id x0HMXALe004358

During attempts to build curl 7.63.0 (and earlier), to resolve known
vulnerabilities, difficulty was encountered with libssh2 releases
above 1.2.4 as follows:

    $ CFLAGS="-static" ./configure \
      --with-libssl-prefix=/usr/local \
        --prefix=/csdi/src/sco507/root/usr/local
    ...
      version:          1.8.0
      Host type:        i686-pc-sco3.2v5.0.7
      Install prefix:   /csdi/src/sco507/root/usr/local
      Compiler:         gcc
      Compiler flags:   -static -D_XOPEN_SOURCE_EXTENDED
      Library types:    Shared=yes, Static=yes
      Crypto library:   OpenSSL (AES-CTR: no)
      Clear memory:     unsupported
      Debug build:      no
      Build examples:   no
      Path to sshd:     /etc/sshd (only for self-tests)
      zlib compression: no

    $ make
    Making all in src
    ...
    Making all in example
    make[1]: Entering directory
      `/csdi/src/sco507/libssh2/libssh2-1.2.4/example'
    make  all-am
    make[2]: Entering directory
      `/csdi/src/sco507/libssh2/libssh2-1.2.4/example'
    source='direct_tcpip.c' object='direct_tcpip.o' libtool=no \
    DEPDIR=.deps depmode=gcc /bin/ksh ../depcomp \
    gcc -DHAVE_CONFIG_H   -I../include -I../example
      -I/csdi/admin/kevinb/include -static -c direct_tcpip.c
    direct_tcpip.c: In function `main':
    direct_tcpip.c:48: `socklen_t' undeclared (first use in this function)
    direct_tcpip.c:48: (Each undeclared identifier is reported only once
    direct_tcpip.c:48: for each function it appears in.)
    direct_tcpip.c:48: parse error before `sinlen'
    direct_tcpip.c:166: `sinlen' undeclared (first use in this function)
    make[2]: *** [direct_tcpip.o] Error 1
    make[2]: Leaving directory
      `/csdi/src/sco507/libssh2/libssh2-1.2.4/example'
    make[1]: *** [all] Error 2
    make[1]: Leaving directory
      `/csdi/src/sco507/libssh2/libssh2-1.2.4/example'
    make: *** [all-recursive] Error 1

socklen_t is not defined on this host type, but, it is noted that other
FOSS projects workaround this limitation.  For example, in curl 7.61.0
and above, the file include/curl/system.h works around this with a
typedef that kicks in when SCO_DS is not defined:

    #elif defined(__GNUC__) && !defined(_SCO_DS)
    ...
    #else
    /* generic "safe guess" on old 32 bit style */
    # define CURL_TYPEOF_CURL_OFF_T     long
    # define CURL_FORMAT_CURL_OFF_T     "ld"
    # define CURL_FORMAT_CURL_OFF_TU    "lu"
    # define CURL_SUFFIX_CURL_OFF_T     L
    # define CURL_SUFFIX_CURL_OFF_TU    UL
    # define CURL_TYPEOF_CURL_SOCKLEN_T int
    #endif

It could be helpful for the libssh2 project to consider a socklen_t
workaround for these systems.  The following patch against the
1.8.0 release resolves compilation issues on this platform:

$ cat libssh2-1.8.0-i686-pc-sco3.2v5.0.7.patch
diff -ru libssh2-1.8.0/include/libssh2.h
libssh2-1.8.0-patch1/include/libssh2.h
--- libssh2-1.8.0/include/libssh2.h     2016-10-25 01:44:34.000000000 -0500
+++ libssh2-1.8.0-patch1/include/libssh2.h      2019-01-17 14:53:11.000000000
-0600
@@ -114,6 +114,15 @@
 # endif /* LIBSSH2_WIN32 */
 #endif /* LIBSSH2_API */

+#if (defined(_SCO_DS))
+/*
+ * socklen_t is not defined in this system, but, it is noted that other FOSS
+ * projects (i.e. curl include/curl/system.h) define socklen_t in the
+ * following way to work around build issues:
+ */
+typedef int socklen_t;
+#endif
+
 #ifdef HAVE_SYS_UIO_H
 # include <sys/uio.h>
 #endif

The aforementioned patch is clearly very specific to the host type, but any
equivalent patch that may be more generic is certainly better than the
current situation.

To build libssh2 on this host type, once the patch is applied, another
build issue occurs:

    $ patch -p1 -i ../libssh2-1.8.0-i686-pc-sco3.2v5.0.7.patch
    patching file include/libssh2.h
    $ CFLAGS="-static" ./configure \
        --with-libssl-prefix=/usr/local \
          --prefix=/csdi/src/sco507/root/usr/local
    $ make
    Making all in src
    make[1]: Entering directory
      `/csdi/admin/kevinb/src/libssh2/libssh2-1.8.0/src'
    make  all-am
    make[2]: Entering directory
      `/csdi/admin/kevinb/src/libssh2/libssh2-1.8.0/src'
      CC       channel.lo
    In file included from libssh2_priv.h:86,
                     from channel.c:41:
    /usr/include/sys/uio.h:76: parse error before `off_t'
    /usr/include/sys/uio.h:76: warning: no semicolon at end of struct or
      union
    /usr/include/sys/uio.h:80: parse error before `}'
    /usr/include/sys/uio.h:80: warning: data definition has no type or
      storage class
    In file included from libssh2_priv.h:86,
                     from channel.c:41:
    /usr/include/sys/uio.h:96: parse error before `readv'
    /usr/include/sys/uio.h:96: warning: data definition has no type or
      storage class
    /usr/include/sys/uio.h:97: parse error before `writev'
    /usr/include/sys/uio.h:97: warning: data definition has no type or
      storage class
    make[2]: *** [channel.lo] Error 1
    make[2]: Leaving directory
      `/csdi/admin/kevinb/src/libssh2/libssh2-1.8.0/src'
    make[1]: *** [all] Error 2
    make[1]: Leaving directory
      `/csdi/admin/kevinb/src/libssh2/libssh2-1.8.0/src'
    make: *** [all-recursive] Error 1

off_t is mentioned in the same curl code (include/curl/system.h)
where the socklen_t assignment was that helped curl compile.  The fix
for off_t, however, was not so simple as patching in a typedef as the
error actually occurs in a SCO file (/usr/include/sys/uio.h).

In /usr/include/sys/uio.h, the problematic off_t assignment only
occurs when _XOPEN_SOURCE_EXTENDED is not defined.  It is not yet
clear how _XOPEN_SOURCE_EXTENDED might get defined properly, but, the
libssh2 build error is avoided by manually setting the define:

    CFLAGS="-D_XOPEN_SOURCE_EXTENDED".

Once the off_t problem is resolved, make issues a new error:

    $ CC= CFLAGS="-static -D_XOPEN_SOURCE_EXTENDED" ./configure \
        --with-libssl-prefix=/usr/local \
          --prefix=/csdi/src/sco507/root/usr/local
    $ make
    ...
    In file included from /usr/include/sys/termios.h:31,
                     from /usr/include/xpg4v2/termios.h:31,
                     from /usr/include/termios.h:7,
                     from x11.c:23:
    /usr/include/sys/termio.h:584: `LDNAMEMAX' undeclared here (not in a function)
    x11.c: In function `main':
    x11.c:431: `SHUT_RDWR' undeclared (first use in this function)
    x11.c:431: (Each undeclared identifier is reported only once
    x11.c:431: for each function it appears in.)
    make[2]: *** [Makefile:620: x11.o] Error 1
    make[2]: Leaving directory
      '/csdi/src/sco507/libssh2/libssh2-1.8.0/example'
    make[1]: *** [Makefile:441: all] Error 2
    make[1]: Leaving directory
      '/csdi/src/sco507/libssh2/libssh2-1.8.0/example'
    make: *** [Makefile:546: all-recursive] Error 1

Note that x11.c is in an "example" directory, so it is simple enough to
resolve this issue by disable building the examples:

    $ ./configure --help | grep example
      --enable-examples-build Build example applications (this is the default)
      --disable-examples-build
                                Do not build example applications

    $ CC= CFLAGS="-static -D_XOPEN_SOURCE_EXTENDED" ./configure \
        --with-libssl-prefix=/usr/local --disable-examples-build \
          --prefix=/csdi/src/sco507/root/usr/local
    $ make

At this point, the build succeeds with the socklen_t patch being the
only source change.

If nothing else, and if the patch or an equivalent one is not applied,
at least perhaps this post should help anyone else being in such an
unfortunate situation as having to build on this host type.  (We
wanted to build libssh2 to get curl's sftp capability.)

Regards,

Kevin R. Bulgrien
_______________________________________________
libssh2-devel https://cool.haxx.se/cgi-bin/mailman/listinfo/libssh2-devel

From libssh2-devel-bounces@cool.haxx.se  Wed Jan 23 20:13:33 2019
Return-Path: <libssh2-devel-bounces@cool.haxx.se>
Received: from www.haxx.se (mail [127.0.0.1])
	by giant.haxx.se (8.15.2/8.15.2/Debian-4) with ESMTP id x0NJCwVn005992;
	Wed, 23 Jan 2019 20:13:23 +0100
Received: from gproxy1-pub.mail.unifiedlayer.com
 (gproxy1-pub.mail.unifiedlayer.com [69.89.25.95])
 by giant.haxx.se (8.15.2/8.15.2/Debian-4) with ESMTPS id x0NJCtdP005775
 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT)
 for <libssh2-devel@cool.haxx.se>; Wed, 23 Jan 2019 20:12:56 +0100
Received: from cmgw11.unifiedlayer.com (unknown [10.9.0.11])
 by gproxy1.mail.unifiedlayer.com (Postfix) with ESMTP id CE65B7011B6F4
 for <libssh2-devel@cool.haxx.se>; Wed, 23 Jan 2019 11:59:03 -0700 (MST)
Received: from box312.bluehost.com ([69.89.31.112]) by cmsmtp with ESMTP
 id mNjrgr1bpqZYcmNjrguMsu; Wed, 23 Jan 2019 11:59:03 -0700
X-Authority-Reason: nr=8
X-Authority-Analysis: $(_cmae_reason
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed;
 d=thehouseofyeager.com; s=default; h=Content-Transfer-Encoding:Content-Type:
 MIME-Version:Date:Message-ID:Subject:From:To:Sender:Reply-To:Cc:Content-ID:
 Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc
 :Resent-Message-ID:In-Reply-To:References:List-Id:List-Help:List-Unsubscribe:
 List-Subscribe:List-Post:List-Owner:List-Archive;
 bh=z53H+fplVy2HewlT6CWuEniO5DkuI/0xeyg2yieyMQ8=; b=BlMX/WRRyMhrvAsS5SbFw+IyOG
 p30kvdKJQSLT7ulqBbqyulWKdzAirkOllCgKASARkMRmeNUYUn4TtTYvd6wLHcMWy+d7rznDHoCwo
 R/XbYdqVes/Oryo6CcxiKwXEt;
Received: from [192.229.234.2] (port=4277 helo=[100.64.0.250])
 by box312.bluehost.com with esmtpsa (TLSv1.2:ECDHE-RSA-AES128-GCM-SHA256:128)
 (Exim 4.91) (envelope-from <dsyeager@thehouseofyeager.com>)
 id 1gmNjr-0046hd-7Q
 for libssh2-devel@cool.haxx.se; Wed, 23 Jan 2019 11:59:03 -0700
To: libssh2-devel@cool.haxx.se
From: Scott Yeager <dsyeager@thehouseofyeager.com>
Subject: User Certificate Authentication using the
 libssh2_userauth_publickey_frommemory C++ api
Message-ID: <9de72e0d-ba54-fef2-d74c-655a0ce49975@thehouseofyeager.com>
Date: Wed, 23 Jan 2019 10:58:59 -0800
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101
 Thunderbird/52.9.1
MIME-Version: 1.0
Content-Language: en-US
X-AntiAbuse: This header was added to track abuse,
 please include it with any abuse report
X-AntiAbuse: Primary Hostname - box312.bluehost.com
X-AntiAbuse: Original Domain - cool.haxx.se
X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12]
X-AntiAbuse: Sender Address Domain - thehouseofyeager.com
X-BWhitelist: no
X-Source-IP: 192.229.234.2
X-Source-L: No
X-Exim-ID: 1gmNjr-0046hd-7Q
X-Source: 
X-Source-Args: 
X-Source-Dir: 
X-Source-Sender: ([100.64.0.250]) [192.229.234.2]:4277
X-Source-Auth: dsyeager@thehouseofyeager.com
X-Email-Count: 1
X-Source-Cap: dGhlaG91dDU7dGhlaG91dDU7Ym94MzEyLmJsdWVob3N0LmNvbQ==
X-Local-Domain: yes
X-BeenThere: libssh2-devel@cool.haxx.se
X-Mailman-Version: 2.1.22
Precedence: list
List-Id: libssh2 development <libssh2-devel.cool.haxx.se>
List-Unsubscribe: <https://cool.haxx.se/cgi-bin/mailman/options/libssh2-devel>, 
 <mailto:libssh2-devel-request@cool.haxx.se?subject=unsubscribe>
List-Archive: <http://cool.haxx.se/pipermail/libssh2-devel/>
List-Post: <mailto:libssh2-devel@cool.haxx.se>
List-Help: <mailto:libssh2-devel-request@cool.haxx.se?subject=help>
List-Subscribe: <https://cool.haxx.se/cgi-bin/mailman/listinfo/libssh2-devel>, 
 <mailto:libssh2-devel-request@cool.haxx.se?subject=subscribe>
Reply-To: libssh2 development <libssh2-devel@cool.haxx.se>
Content-Type: text/plain; charset="utf-8"; Format="flowed"
Errors-To: libssh2-devel-bounces@cool.haxx.se
Sender: "libssh2-devel" <libssh2-devel-bounces@cool.haxx.se>
Content-Transfer-Encoding: 8bit
X-MIME-Autoconverted: from base64 to 8bit by giant.haxx.se id x0NJCwVn005992

I have a C++ application that uses the 
libssh2_userauth_publickey_frommemory api when running commands on 
remote servers. I'm using libssh2 1.8.0.

The application has been working fine with normal keys for 6 or so years 
now but I now need it to work with user certificates.

https://support.ssh.com/manuals/server-admin/64/userauth-cert.html

Our new key generation logic produces a private key, a pub key and a pub 
cert.

     -rw------- 1 587204286 587204286  411 Jan 22 14:02 id_ed25519
     -rw-r--r-- 1 587204286 587204286  101 Jan 22 14:02 id_ed25519.pub
     -rw-r--r-- 1 587204286 587204286 1891 Jan 23 17:17 id_ed25519-cert.pub

They work properly with the normal ssh command.

     [Wed Jan 23 17:26:39] root@mon034.bur:~/src/event_ssh-src# ssh -i 
.ssh/id_ed25519 root@cache101.cha "uptime"
      18:52:21 up 85 days, 13:14,  1 user,  load average: 4.64, 4.33, 4.22

Prior to this I've always passed a NULL and 0 for the public key string 
and length.

Trying to get the user certificate to work I've been trying to pass it 
(id_ed25519-cert.pub's content) in as the public key. I've also tried it 
as the private key and a few other combinations.

But keep getting

[Wed Jan 23 18:51:26] root@mon034.bur:~/src/event_ssh-src# 
build/src/event_ssh --canary="" --cmd=uptime --servers=cache101.cha 
--user=root --key=.ssh/id_ed25519 --pub-key=.ssh/id_ed25519-cert.pub
read priv key from .ssh/id_ed25519
read pub key from .ssh/id_ed25519-cert.pub
called libssh2_userauth_publickey_frommemory, username: root, pub key 
len: 1891, priv key len: 411
[1/1] cache101.cha      Authentication by public key failed, rc: -19, 
The username/public key combination was invalid.


Has anyone gotten authentication with user certificates to work with 
libssh2, if so what needs to be done differently compared to just using 
a normal private key?

Thanks,
Scott Yeager

_______________________________________________
libssh2-devel https://cool.haxx.se/cgi-bin/mailman/listinfo/libssh2-devel

