tag:help.appveyor.com,2012-11-13:/discussions/problems/33606-try-to-deploy-sftp-to-sourceforge-error-cannot-connect-sftp-server-failed-to-negotiate-key-exchange-algorithmAppVeyor: Discussion 2022-11-15T20:48:48Ztag:help.appveyor.com,2012-11-13:Comment/567433822022-11-14T00:25:20Z2022-11-14T00:25:20ZTry to deploy (SFTP) to Sourceforge: Error - Cannot connect SFTP server: Failed to negotiate key exchange algorithm.<div><p>Hi Andre,</p>
<p>Checking the logs I see that both successful and failed builds have been running on <code>Visual Studio 2015</code> image and in the same build environment. <code>Visual Studio 2015</code> image wasn't changed for the last 3 months. Build Agent was not updated during that period as well.</p>
<p>However, that <a href="https://ci.appveyor.com/project/AndreMikulec/appveyortest4">https://ci.appveyor.com/project/AndreMikulec/appveyortest4</a> project is running on <code>Visual Studio 2019</code> image and gives the same error which is strange.</p>
<p>I suspect something changed on SF side (like an update exchange algorithm?) which is not yet supported by a SFTP library used in AppVeyor Build Agent.</p>
<p>You can try using WinSCP for deployment to SF.</p>
<p>The general algorithm for using WinSCP in a build script:</p>
<pre>
<code>deploy_script:
- cmd: |
choco install -y winscp
echo open ftpes://%FTP_USER%:%FTP_PSW%@<your-ftp-server>/ > ftp.txt
echo put <somefile> / >> ftp.txt
echo exit >> ftp.txt
"C:\Program Files (x86)\WinSCP\winscp.com" /script=ftp.txt</code>
</pre>
<p>where FTP_USER and FTP_PSW are secure environment variables defined on either project settings UI or in appveyor.yml.</p>
<p>Let me know if that worked.</p></div>Feodor Fitsnertag:help.appveyor.com,2012-11-13:Comment/567433822022-11-15T02:07:36Z2022-11-15T02:07:36ZTry to deploy (SFTP) to Sourceforge: Error - Cannot connect SFTP server: Failed to negotiate key exchange algorithm.<div><p>Feodor Fitsner,</p>
<p>Short answer: the situation may be? . . .<br>
"The server's host key was not found in the cache."</p>
<p>Long answer:</p>
<p>In this particular case, this SFTP host is on Sourceforge.<br>
In this help request, everything is public knowledge EXCEPT my password %FTP_PSW%.</p>
<p>Sourceforge docs that I followed.<br>
<a href="https://sourceforge.net/p/forge/documentation/SFTP/">https://sourceforge.net/p/forge/documentation/SFTP/</a></p>
<p>MY_PASSWORD is not "my password".<br>
I stored my real password in the web interface Appveyor environment variable FTP_PSW.</p>
<p>Here are results . .</p>
<p>I tried locally using ftpes:<br></p>
<pre>
<code>C:\Users\AnonymousUser\Downloads>type ftp.txt
open ftpes://andremikulec,andremikulec.u:MY_PASSWORD@frs.sourceforge.net/
put ALPHA.txt /home/frs/project/andremikulec/
exit</code>
</pre>
<p>local sftpes output:<br></p>
<pre>
<code>C:\Users\AnonymousUser\Downloads>winscp.com /script=ftp.txt
Connecting to frs.sourceforge.net ...
Connection failed.
Timeout detected. (control connection)
Connection failed.</code>
</pre>
<p>Following "open command"<br>
<a href="https://winscp.net/eng/docs/scriptcommand_open">https://winscp.net/eng/docs/scriptcommand_open</a><br>
I tried locally using sftp:<br></p>
<pre>
<code>C:\Users\AnonymousUser\Downloads>type ftp_frs_2.txt
open sftp://andremikulec,andremikulec.u:MY_PASSWORD@frs.sourceforge.net/
put ALPHA.txt /home/frs/project/andremikulec/</code>
</pre>
<p>local sftp output:<br></p>
<pre>
<code>C:\Users\AnonymousUser\Downloads>winscp.com /script=ftp_frs_2.txt
Searching for host...
Connecting to host...
Authenticating...
Using username "andremikulec,andremikulec.u".
Authenticating with pre-entered password.
Authenticated.
Starting the session...
Session started.
Active session: [1] andremikulec,andremikulec.u@frs.sourceforge.net
Using configured transfer settings different from factory defaults.
ALPHA.txt | 7 B | 0.0 KB/s | ascii | 100%</code>
</pre>
<p>I tried online using ftpes:<br>
<a href="https://github.com/AndreMikulec/appveyortest4/blob/b8a108d9a30052356c9898c0e08dea08f4ff2cad/appveyor.yml#L25">https://github.com/AndreMikulec/appveyortest4/blob/b8a108d9a3005235...</a><br></p>
<pre>
<code>deploy_script:
- cmd: |
choco install -y winscp
echo open ftpes://andremikulec,andremikulec.u:%FTP_PSW%@frs.sourceforge.net/ > ftp.txt 2>&1 || date /t
echo put ALPHA.txt /home/frs/project/andremikulec/ >> ftp.txt
echo exit >> ftp.txt
set PATH=C:\Program Files (x86)\WinSCP;%PATH%
winscp.com /script=ftp.txt</code>
</pre>
<p>online ftpes output:<br>
<a href="https://ci.appveyor.com/project/AndreMikulec/appveyortest4/builds/45381767#L58">https://ci.appveyor.com/project/AndreMikulec/appveyortest4/builds/4...</a><br></p>
<pre>
<code>echo open ftpes://andremikulec,andremikulec.u:%FTP_PSW%@frs.sourceforge.net/ > ftp.txt 2>&1 || date /t
echo put ALPHA.txt /home/frs/project/andremikulec/ >> ftp.txt
echo exit >> ftp.txt
set PATH=C:\Program Files (x86)\WinSCP;%PATH%
winscp.com /script=ftp.txt
Connecting to frs.sourceforge.net ...
Connection failed.
Timeout detected. (control connection)
Connection failed.
Command exited with code 1</code>
</pre>
<p>I tried online using sftp:<br>
<a href="https://github.com/AndreMikulec/appveyortest4/blob/2515b789a12e97267b85a91823b65bc6ced246f9/appveyor.yml#L25">https://github.com/AndreMikulec/appveyortest4/blob/2515b789a12e9726...</a><br></p>
<pre>
<code>deploy_script:
- cmd: |
choco install -y winscp
echo open sftp://andremikulec,andremikulec.u:%FTP_PSW%@frs.sourceforge.net/ > ftp.txt 2>&1 || date /t
echo put ALPHA.txt /home/frs/project/andremikulec/ >> ftp.txt
echo exit >> ftp.txt
set PATH=C:\Program Files (x86)\WinSCP;%PATH%
winscp.com /script=ftp.txt</code>
</pre>
<p>online sftp output:<br>
<a href="https://ci.appveyor.com/project/AndreMikulec/appveyortest4/builds/45381785#L58">https://ci.appveyor.com/project/AndreMikulec/appveyortest4/builds/4...</a><br></p>
<pre>
<code>echo open sftp://andremikulec,andremikulec.u:%FTP_PSW%@frs.sourceforge.net/ > ftp.txt 2>&1 || date /t
echo put ALPHA.txt /home/frs/project/andremikulec/ >> ftp.txt
echo exit >> ftp.txt
set PATH=C:\Program Files (x86)\WinSCP;%PATH%
winscp.com /script=ftp.txt
Searching for host...
Connecting to host...
Authenticating...
Continue connecting to an unknown server and add its host key to a cache?
The server's host key was not found in the cache. You have no guarantee that the server is the computer you think it is.
The server's Ed25519 key details are:
Algorithm: ssh-ed25519 255
SHA-256: 209BDmH3jsRyO9UeGPPgLWPSegKmYCBIya0nR/AWWCY
MD5: 6e:b2:16:7a:ee:b6:c2:23:c5:8f:ff:e7:9d:cd:d4:1a
If you trust this host, press Yes. To connect without adding host key to the cache, press No. To abandon the connection press Cancel.
In scripting, you should use a -hostkey switch to configure the expected host key.
(Y)es, (N)o, C(a)ncel (10 s), (C)opy Key, (P)aste key:
Host key wasn't verified!
Host key fingerprint is ssh-ed25519 255 209BDmH3jsRyO9UeGPPgLWPSegKmYCBIya0nR/AWWCY.
Authentication failed.
Command exited with code 1</code>
</pre>
<p>I followed this:<br>
<a href="https://winscp.net/eng/docs/scriptcommand_open">https://winscp.net/eng/docs/scriptcommand_open</a><br></p>
<pre>
<code>-hostkey="<fingerprint>"
-hostkey="acceptnew"</code>
</pre>
<p>I tried online using sftp:<br>
<a href="https://github.com/AndreMikulec/appveyortest4/blob/40c7d4b7388e6985ce6a23752b9910e1e7fafc58/appveyor.yml#L25">https://github.com/AndreMikulec/appveyortest4/blob/40c7d4b7388e6985...</a><br></p>
<pre>
<code>deploy_script:
- cmd: |
choco install -y winscp
echo open sftp://andremikulec,andremikulec.u:%FTP_PSW%@frs.sourceforge.net/ -hostkey="acceptnew" > ftp.txt 2>&1 || date /t
echo put ALPHA.txt /home/frs/project/andremikulec/ >> ftp.txt
echo exit >> ftp.txt
set PATH=C:\Program Files (x86)\WinSCP;%PATH%
winscp.com /script=ftp.txt</code>
</pre>
<p>online sftp output:<br>
<a href="https://ci.appveyor.com/project/AndreMikulec/appveyortest4/builds/45381930#L58">https://ci.appveyor.com/project/AndreMikulec/appveyortest4/builds/4...</a><br></p>
<pre>
<code>echo open sftp://andremikulec,andremikulec.u:%FTP_PSW%@frs.sourceforge.net/ -hostkey="acceptnew" > ftp.txt 2>&1 || date /t
echo put ALPHA.txt /home/frs/project/andremikulec/ >> ftp.txt
echo exit >> ftp.txt
set PATH=C:\Program Files (x86)\WinSCP;%PATH%
winscp.com /script=ftp.txt
Searching for host...
Connecting to host...
Authenticating...
Using username "andremikulec,andremikulec.u".
Authenticating with pre-entered password.
Authenticated.
Starting the session...
Session started.
Active session: [1] andremikulec,andremikulec.u@frs.sourceforge.net
ALPHA.txt | 8 B | 0.0 KB/s | binary | 100%
Build success</code>
</pre>
<p>What happens next?</p>
<p>Thanks,<br>
Andre</p></div>andre_mikulectag:help.appveyor.com,2012-11-13:Comment/567433822022-11-15T04:16:56Z2022-11-15T04:16:56ZTry to deploy (SFTP) to Sourceforge: Error - Cannot connect SFTP server: Failed to negotiate key exchange algorithm.<div><p>Hi Andre,</p>
<p>Thanks for your time investigating this! That knowledge will definitely help other AppVeyor users having the same issues/requirements!</p>
<p>If it works with WinSCP then use it going forward.</p>
<p>I will try looking if that could be implemented with .NET FTP library used in AppVeyor Build Agent, but honestly we have never been able to find a decent .NET FTP client with OS license.</p></div>Feodor Fitsnertag:help.appveyor.com,2012-11-13:Comment/567433822022-11-15T20:48:48Z2022-11-15T20:48:48ZTry to deploy (SFTP) to Sourceforge: Error - Cannot connect SFTP server: Failed to negotiate key exchange algorithm.<div><p><code>If it works with WinSCP then use it going forward.</code> O.K. Thanks</p></div>andre_mikulec