WinSCP, .NET library, checksum support - ftp

I'm using the WinSCP .NET library. Occasionally, the session.CalculateFileChecksum() call will throw an exception when a server does not support the checksum functionality.
I'd like to avoid this by first checking whether or not the FTP server supports the call. I'm wondering if there is a way to do this using the .NET library API.
Any thoughts?
Note: I already know I can do this using the WinSCP GUI. Need an API/C# solution.
TIA

There's no API for that.
All you can do is to try, catch an exception and test its message for:
Operation not supported.
Or you can enable session logging and parse the log file for a response to FEAT command, looking for HASH, XSHA1, XSHA256, XSHA512, XMD5, MD5 or XCRC (that's what WinSCP does internally).
> 2018-10-17 19:16:53.910 FEAT
< 2018-10-17 19:16:53.910 211-Features:
< 2018-10-17 19:16:53.910 MDTM
< 2018-10-17 19:16:53.910 REST STREAM
< 2018-10-17 19:16:53.910 SIZE
< 2018-10-17 19:16:53.910 MLST type*;size*;modify*;
< 2018-10-17 19:16:53.910 MLSD
< 2018-10-17 19:16:53.910 AUTH SSL
< 2018-10-17 19:16:53.910 AUTH TLS
< 2018-10-17 19:16:53.910 PROT
< 2018-10-17 19:16:53.910 PBSZ
< 2018-10-17 19:16:53.910 UTF8
< 2018-10-17 19:16:53.910 CLNT
< 2018-10-17 19:16:53.910 MFMT
< 2018-10-17 19:16:53.910 HASH SHA-1*;SHA-512;MD5
< 2018-10-17 19:16:53.910 EPSV
< 2018-10-17 19:16:53.910 EPRT
< 2018-10-17 19:16:53.910 211 End

Related

all_proxy hang without sudo while using proxy in golang

some of my computers' behavior are different when I using a proxy code by golang, with https. While http is always ok.
for example:
for some normal computer ( Mac )
the right one:
all_proxy=ip:port curl -vv -k https://baidu.com
---> it works
In some computer (also, Mac):
all_proxy=ip:port curl -vv -k https://baidu.com
* Uses proxy env variable all_proxy == 'ip:port'
* Trying ip...
* TCP_NODELAY set
* Connected to ip (ip) port port (#0)
* allocate connect buffer!
* Establish HTTP proxy tunnel to baidu.com:443
> CONNECT baidu.com:443 HTTP/1.1
> Host: baidu.com:443
> User-Agent: curl/7.64.1
> Proxy-Connection: Keep-Alive
>
< HTTP/1.1 200 OK
< Date: Fri, 07 May 2021 06:28:57 GMT
< Transfer-Encoding: chunked
* Ignoring Transfer-Encoding in CONNECT 200 response
<
* Proxy replied 200 to CONNECT request
* CONNECT phase completed!
* ALPN, offering h2
* ALPN, offering http/1.1
* successfully set certificate verify locations:
* CAfile: /etc/ssl/cert.pem
CApath: none
* TLSv1.2 (OUT), TLS handshake, Client hello (1):
* LibreSSL SSL_connect: SSL_ERROR_SYSCALL in connection to baidu.com:443
* Closing connection 0
curl: (35) LibreSSL SSL_connect: SSL_ERROR_SYSCALL in connection to baidu.com:443
--- > it does not work ?!
However, in this case, if I use sudo , it works!
sudo all_proxy=ip:port curl -vv -k https://baidu.com
* Uses proxy env variable all_proxy == 'ip:port'
* Trying ip...
* TCP_NODELAY set
* Connected to ip (ip) port port (#0)
* allocate connect buffer!
* Establish HTTP proxy tunnel to baidu.com:443
> CONNECT baidu.com:443 HTTP/1.1
> Host: baidu.com:443
> User-Agent: curl/7.64.1
> Proxy-Connection: Keep-Alive
>
< HTTP/1.1 200 OK
< Date: Fri, 07 May 2021 06:27:18 GMT
< Transfer-Encoding: chunked
* Ignoring Transfer-Encoding in CONNECT 200 response
<
* Proxy replied 200 to CONNECT request
* CONNECT phase completed!
* ALPN, offering h2
* ALPN, offering http/1.1
* successfully set certificate verify locations:
* CAfile: /etc/ssl/cert.pem
CApath: none
* TLSv1.2 (OUT), TLS handshake, Client hello (1):
* CONNECT phase completed!
* CONNECT phase completed!
* TLSv1.2 (IN), TLS handshake, Server hello (2):
* TLSv1.2 (IN), TLS handshake, Certificate (11):
* TLSv1.2 (IN), TLS handshake, Server key exchange (12):
* TLSv1.2 (IN), TLS handshake, Server finished (14):
* TLSv1.2 (OUT), TLS handshake, Client key exchange (16):
* TLSv1.2 (OUT), TLS change cipher, Change cipher spec (1):
* TLSv1.2 (OUT), TLS handshake, Finished (20):
* TLSv1.2 (IN), TLS change cipher, Change cipher spec (1):
* TLSv1.2 (IN), TLS handshake, Finished (20):
* SSL connection using TLSv1.2 / ECDHE-RSA-AES128-GCM-SHA256
* ALPN, server accepted to use http/1.1
* Server certificate:
* subject: C=CN; ST=\U5317\U4EAC\U5E02; O=BeiJing Baidu Netcom Science Technology Co., Ltd; CN=www.baidu.cn
* start date: Jan 25 00:00:00 2021 GMT
* expire date: Feb 24 23:59:59 2022 GMT
* issuer: C=US; O=DigiCert Inc; CN=DigiCert Secure Site Pro CN CA G3
* SSL certificate verify ok.
> GET / HTTP/1.1
> Host: baidu.com
> User-Agent: curl/7.64.1
> Accept: */*
>
< HTTP/1.1 302 Moved Temporarily
< Server: bfe/1.0.8.18
< Date: Fri, 07 May 2021 06:27:18 GMT
< Content-Type: text/html
< Content-Length: 161
< Connection: keep-alive
< Location: http://www.baidu.com/
<
<html>
<head><title>302 Found</title></head>
<body bgcolor="white">
<center><h1>302 Found</h1></center>
<hr><center>bfe/1.0.8.18</center>
</body>
</html>
* Connection #0 to host ip left intact
* Closing connection 0
----- I totally don't know why.
It seems hang on the first "HELLO" after the proxy connect to the target website and "HELLO" didn't send out.
this problem only occur if the proxy server is code by golang, if I use a proxy server code by python, it will work.
also, if the proxy server is on the same computer, it will work in localhost only:
all_proxy=127.0.0.1:8080 curl -vv -k https://baidu.com ---> work!
all_proxy=192.168.0.1:8080 curl -vv -k https://baidu.com ---> not work!
pls help.

Gulp Vinyl FTP ECONNRESET error after FEAT command

I am attempting to use the gulp-vinyl-ftp plugin to upload to a remote site.
gulp.task("deploy", ["default"], function () {
var conn = ftp.create({
host: "mywebsite",
user: "****",
password: "******",
// secure: true,
timeOffset: -301,
parallel: 1,
debug: gutil.log
});
var globs = [
"distr/**/*.php",
"!out/vendor/**",
"!out/config.php",
"out/**/*.map",
"out/**/*.css",
"out/**/*.js"
];
return gulp.src(globs)
.pipe(conn.newer("/")).pipe(debug({ title: "Deploy New: " }))
});
However, I am receiving the following error:
events.js:182
throw er; // Unhandled 'error' event
^
Error: read ECONNRESET
at exports._errnoException (util.js:1016:11)
at TCP.onread (net.js:609:25)
The debug output is as follows:
[08:37:28] [connection] < '220 Microsoft FTP Service\r\n'
[08:37:28] [parser] < '220 Microsoft FTP Service\r\n'
[08:37:28] [parser] Response: code=220, buffer='Microsoft FTP Service'
[08:37:28] [connection] > 'USER xxx'
[08:37:29] [connection] < '331 Password required\r\n'
[08:37:29] [parser] < '331 Password required\r\n'
[08:37:29] [parser] Response: code=331, buffer='Password required'
[08:37:29] [connection] > 'PASS xxxx'
[08:37:29] [connection] < '230 User logged in.\r\n'
[08:37:29] [parser] < '230 User logged in.\r\n'
[08:37:29] [parser] Response: code=230, buffer='User logged in.'
[08:37:29] [connection] > 'FEAT'
It ends there.
However, I can connect just fine through WinSCP.
. 2017-11-08 08:36:24.161 Connecting to mywebsite ...
. 2017-11-08 08:36:24.192 Connected with mywebsite. Waiting for welcome message...
< 2017-11-08 08:36:24.285 220 Microsoft FTP Service
> 2017-11-08 08:36:24.285 USER xxxx
< 2017-11-08 08:36:24.379 331 Password required
> 2017-11-08 08:36:25.861 PASS ********
< 2017-11-08 08:36:25.970 230 User logged in.
> 2017-11-08 08:36:25.970 SYST
. 2017-11-08 08:36:26.064 The server is probably running Windows, assuming that directory listing timestamps are affected by DST.
< 2017-11-08 08:36:26.064 215 Windows_NT
> 2017-11-08 08:36:26.064 FEAT
< 2017-11-08 08:36:26.157 211-Extended features supported:
< 2017-11-08 08:36:26.157 LANG EN*
< 2017-11-08 08:36:26.157 UTF8
< 2017-11-08 08:36:26.157 AUTH TLS;TLS-C;SSL;TLS-P;
< 2017-11-08 08:36:26.157 PBSZ
< 2017-11-08 08:36:26.157 PROT C;P;
< 2017-11-08 08:36:26.157 CCC
< 2017-11-08 08:36:26.157 HOST
< 2017-11-08 08:36:26.157 SIZE
< 2017-11-08 08:36:26.157 MDTM
< 2017-11-08 08:36:26.157 REST STREAM
< 2017-11-08 08:36:26.157 211 END
> 2017-11-08 08:36:26.157 OPTS UTF8 ON
< 2017-11-08 08:36:26.251 200 OPTS UTF8 command successful - UTF8 encoding now ON.
. 2017-11-08 08:36:26.298 Connected
I have tried both the IP address and domain name in the host field, commenting out the the timeOffset and parallel options.
I am not sure where to go from here honestly; any advice would be appreciated.
Thanks.
You will find lot of posts about IIS mysteriously (and inconsistently) closing a connection after receiving FEAT command.
I have not found any definitive solution, but working workaround seems to be to deny the FEAT command (if Gulp can handle that).
In IIS manager, go to FTP > FTP Request Filtering > Commands tab > Actions > Deny command and type FEAT.
See also Microsoft FTP fails to connect after the client requests the list of features (FEAT).

How to get a string in the output of curl command in Unix shell scripting?

I am looking to cut the task number which is highlighted in the output. However, normal grep or sed commands or redirection to text file for getting the desired output is not working. As the curl is writing on the terminal screen, these operations arent working. Please suggest.
vcap#jumpbox-sagdf-staging:~ $ curl -v -s -k 'https://admin:88uudjdjd#10.19.1.1:25555/deployments/concourse/vms?format=full'
* Hostname was NOT found in DNS cache
Trying 10.19.1.1....
Connected to 10.19.1.1 (10.19.1.1) port 25555 (#0)
successfully set certificate verify locations:
CAfile: none
CApath: /etc/ssl/certs
SSLv3, TLS handshake, Client hello (1):
SSLv3, TLS handshake, Server hello (2):
SSLv3, TLS handshake, CERT (11):
SSLv3, TLS handshake, Server key exchange (12):
SSLv3, TLS handshake, Server finished (14):
SSLv3, TLS handshake, Client key exchange (16):
SSLv3, TLS change cipher, Client hello (1):
SSLv3, TLS handshake, Finished (20):
SSLv3, TLS change cipher, Client hello (1):
SSLv3, TLS handshake, Finished (20):
SSL connection using ECDHE-RSA-AES128-GCM-SHA256
Server certificate:
subject: CN=director
start date: 2017-06-20 13:19:23 GMT
expire date: 2019-06-20 13:19:23 GMT
issuer: CN=rootCA
SSL certificate verify result: unable to get local issuer certificate (20), continuing anyway.
Server auth using Basic with user 'admin'
GET /deployments/concourse/vms?format=full HTTP/1.1
Authorization: Basic YWRtaW46OHdId1lEVlIwakJCZ3c=
User-Agent: curl/7.35.0
Host: 10.19.1.1:25555
Accept: /
>
< HTTP/1.1 302 Moved Temporarily
Server nginx is not blacklisted
< Server: nginx
< Date: Fri, 30 Jun 2017 04:07:19 GMT
< Content-Type: text/html;charset=utf-8
< Content-Length: 0
< Connection: keep-alive
< WWW-Authenticate: Basic realm="BOSH Director"
< Location: https://10.19.1.1/tasks/1017317
< X-XSS-Protection: 1; mode=block
< X-Content-Type-Options: nosniff
< X-Frame-Options: SAMEORIGIN
<
Connection #0 to host 10.19.1.1 left intact
Since you want to extract the piece on the right of the right-most slash of the Location: response header, I would use this:
curl -so /dev/null -w "%{redirect_url}\n" $URL | sed 's:.*/::g'
so that with your original URL use case it would look like (I added the -k back in this version):
curl -kso /dev/null -w "%{redirect_url}\n" 'https://admin:88uudjdjd#10.19.1.1:25555/deployments/concourse/vms?format=full' | sed 's:.*/::g'
(Do note that you've exposed your user name and password to the world here...)

gnutls_record_recv: The TLS connection was non-properly terminated. Assuming EOF

I am attempting to use the Gitlab pipeline ci in order to build my site and deploy it to my GoDaddy hosting via FTPS. Right now everything is being done as dry-runs. If I attempt to transfer to a new directory from my top level domain (www.mysite.com/build) the command will execute successfully both on my local machine as well as in the Gitlab pipeline. However, if I attempt to overwrite the files from the top-level domain to actually update the site, it only works on my local but fails to connect from the Gitlab Pipeline.
Command to transfer to a new directory:
(Dry-run executes fine from my Gitlab.com and from my local machine)
lftp -e "set ftp:ssl-force; set ssl:verify-certificate no; mirror -R --dry-run build/ ; quit" -u $FTP_USER,$FTP_PASSWORD $FTP_HOST --debug
Command to transfer to the top-level domain, overwriting existing code:
(Dry-run execute fine from my local machine but never manages to connect properly from Gitab.com)
lftp -e "set ftp:ssl-force; set ssl:verify-certificate no; mirror -R --dry-run build/ / ; quit" -u $FTP_USER,$FTP_PASSWORD $FTP_HOST --debug
I suspect this may be a problem with either GoDaddy or Gitlab's setup, but I wanted to check here first to see if I was missing any obvious mistakes.
I have included the logs below with the --debug flag set.
Transfer to new directory (/build)
Gitlab.com (working)
$ lftp -e "set ftp:ssl-force; set ssl:verify-certificate no; mirror -R --dry-run build/ ; quit" -u $FTP_USER,$FTP_PASSWORD $FTP_HOST --debug
---- Connecting to <my_domain>.com (160.153.92.9) port 21
<--- 220---------- Welcome to Pure-FTPd [privsep] [TLS] ----------
<--- 220-You are user number 1 of 500 allowed.
<--- 220-Local time is now 17:25. Server port: 21.
<--- 220-This is a private system - No anonymous login
<--- 220 You will be disconnected after 15 minutes of inactivity.
---> FEAT
<--- 211-Extensions supported:
<--- EPRT
<--- IDLE
<--- MDTM
<--- SIZE
<--- MFMT
<--- REST STREAM
<--- MLST type*;size*;sizd*;modify*;UNIX.mode*;UNIX.uid*;UNIX.gid*;unique*;
<--- MLSD
<--- AUTH TLS
<--- PBSZ
<--- PROT
<--- UTF8
<--- TVFS
<--- ESTA
<--- PASV
<--- EPSV
<--- SPSV
<--- ESTP
<--- 211 End.
---> AUTH TLS
<--- 234 AUTH TLS OK.
---> OPTS UTF8 ON
Certificate: EMAIL=ssl#p3plcpnl0953.prod.phx3.secureserver.net,CN=p3plcpnl0953.prod.phx3.secureserver.net
Issued by: EMAIL=ssl#p3plcpnl0953.prod.phx3.secureserver.net,CN=p3plcpnl0953.prod.phx3.secureserver.net
WARNING: Certificate verification: Not trusted
WARNING: Certificate verification: certificate common name doesn't match requested host name '<my_domain>.com'
<--- 200 OK, UTF-8 enabled
---> OPTS MLST type;size;modify;UNIX.mode;UNIX.uid;UNIX.gid;
<--- 200 MLST OPTS type;size;sizd;modify;UNIX.mode;UNIX.uid;UNIX.gid;unique;
---> USER <my_user>#<my_domain>.com
<--- 331 User <my_user>#<my_domain>.com OK. Password required
---> PASS <my_password>
<--- 230-Your bandwidth usage is restricted
<--- 230 OK. Current restricted directory is /
---> PWD
<--- 257 "/" is your current location
---> PBSZ 0
---- CWD path to be sent is `/build'
<--- 200 PBSZ=0
---> CWD /build
<--- 550 Can't change directory to /build: No such file or directory
---- CWD path to be sent is `/build/amp'
---> CWD /build/amp
<--- 550 Can't change directory to /build/amp: No such file or directory
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
<<< FILES TRANSFERED-- OMITTED FOR BREVITY >>>
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
Creating cache default...
Created cache
Job succeeded
Local Machine (working)
$ lftp -e "set ftp:ssl-force; set ssl:verify-certificate no; mirror -R --dry-run build/ ; quit" -u <my_user>#<my_domain>,<my_password> <my_domain>
mkdir -p ftp://<my_user>#<my_domain>:<my_password>#<my_domain>.com/build/
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
<<< FILES TRANSFERED-- OMITTED FOR BREVITY >>>
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
Total: 48 directories, 299 files, 0 symlinks
New: 299 files, 0 symlinks
$
Transfer to top level domain (overwrite/update)
Gitlab.com **(not working)**
$ lftp -e "set ftp:ssl-force; set ssl:verify-certificate no; mirror -R --dry-run build/ / ; quit" -u $FTP_USER,$FTP_PASSWORD $FTP_HOST --debug
---- Connecting to <my_domain>.com (160.153.92.9) port 21
<--- 220---------- Welcome to Pure-FTPd [privsep] [TLS] ----------
<--- 220-You are user number 1 of 500 allowed.
<--- 220-Local time is now 12:39. Server port: 21.
<--- 220-This is a private system - No anonymous login
<--- 220 You will be disconnected after 15 minutes of inactivity.
---> FEAT
<--- 211-Extensions supported:
<--- EPRT
<--- IDLE
<--- MDTM
<--- SIZE
<--- MFMT
<--- REST STREAM
<--- MLST type*;size*;sizd*;modify*;UNIX.mode*;UNIX.uid*;UNIX.gid*;unique*;
<--- MLSD
<--- AUTH TLS
<--- PBSZ
<--- PROT
<--- UTF8
<--- TVFS
<--- ESTA
<--- PASV
<--- EPSV
<--- SPSV
<--- ESTP
<--- 211 End.
---> AUTH TLS
<--- 234 AUTH TLS OK.
---> OPTS UTF8 ON
Certificate: EMAIL=ssl#p3plcpnl0953.prod.phx3.secureserver.net,CN=p3plcpnl0953.prod.phx3.secureserver.net
Issued by: EMAIL=ssl#p3plcpnl0953.prod.phx3.secureserver.net,CN=p3plcpnl0953.prod.phx3.secureserver.net
WARNING: Certificate verification: Not trusted
WARNING: Certificate verification: certificate common name doesn't match requested host name '<my_domain>.com'
<--- 200 OK, UTF-8 enabled
---> OPTS MLST type;size;modify;UNIX.mode;UNIX.uid;UNIX.gid;
<--- 200 MLST OPTS type;size;sizd;modify;UNIX.mode;UNIX.uid;UNIX.gid;unique;
---> USER <my_user>#<my_domain>.com
<--- 331 User <my_user>#<my_domain>.com OK. Password required
---> PASS <my_password>
<--- 230-Your bandwidth usage is restricted
<--- 230 OK. Current restricted directory is /
---> PWD
<--- 257 "/" is your current location
---> PBSZ 0
<--- 200 PBSZ=0
---> PROT P
<--- 200 Data protection level set to "private"
---> PASV
<--- 227 Entering Passive Mode (160,153,92,9,195,195)
---- Connecting data socket to (160.153.92.9) port 50115
---- Data connection established
---> LIST
<--- 150 Accepted data connection
Certificate: EMAIL=ssl#p3plcpnl0953.prod.phx3.secureserver.net,CN=p3plcpnl0953.prod.phx3.secureserver.net
Issued by: EMAIL=ssl#p3plcpnl0953.prod.phx3.secureserver.net,CN=p3plcpnl0953.prod.phx3.secureserver.net
WARNING: Certificate verification: Not trusted
WARNING: Certificate verification: certificate common name doesn't match requested host name '<my_domain>.com'
gnutls_record_recv: The TLS connection was non-properly terminated. Assuming EOF.
gnutls_record_recv: The TLS connection was non-properly terminated. Assuming EOF.
**** Peer closed connection
---- Closing data socket
---- Closing control socket
---- Connecting to <my_domain>.com (160.153.92.9) port 21
<--- 220---------- Welcome to Pure-FTPd [privsep] [TLS] ----------
<--- 220-You are user number 1 of 500 allowed.
<--- 220-Local time is now 12:40. Server port: 21.
<--- 220-This is a private system - No anonymous login
<--- 220 You will be disconnected after 15 minutes of inactivity.
---> FEAT
<--- 211-Extensions supported:
<--- EPRT
<--- IDLE
<--- MDTM
<--- SIZE
<--- MFMT
<--- REST STREAM
<--- MLST type*;size*;sizd*;modify*;UNIX.mode*;UNIX.uid*;UNIX.gid*;unique*;
<--- MLSD
<--- AUTH TLS
<--- PBSZ
<--- PROT
<--- UTF8
<--- TVFS
<--- ESTA
<--- PASV
<--- EPSV
<--- SPSV
<--- ESTP
<--- 211 End.
---> AUTH TLS
<--- 234 AUTH TLS OK.
---> OPTS UTF8 ON
Certificate: EMAIL=ssl#p3plcpnl0953.prod.phx3.secureserver.net,CN=p3plcpnl0953.prod.phx3.secureserver.net
Issued by: EMAIL=ssl#p3plcpnl0953.prod.phx3.secureserver.net,CN=p3plcpnl0953.prod.phx3.secureserver.net
WARNING: Certificate verification: Not trusted
WARNING: Certificate verification: certificate common name doesn't match requested host name '<my_domain>.com'
<--- 200 OK, UTF-8 enabled
---> OPTS MLST type;size;modify;UNIX.mode;UNIX.uid;UNIX.gid;
<--- 200 MLST OPTS type;size;sizd;modify;UNIX.mode;UNIX.uid;UNIX.gid;unique;
---> USER <my_user>#<my_domain>.com
<--- 331 User <my_user>#<my_domain>.com OK. Password required
---> PASS <my_password>
<--- 230-Your bandwidth usage is restricted
<--- 230 OK. Current restricted directory is /
---> PBSZ 0
<--- 200 PBSZ=0
---> PROT P
<--- 200 Data protection level set to "private"
---> PASV
<--- 227 Entering Passive Mode (160,153,92,9,196,113)
---- Connecting data socket to (160.153.92.9) port 50289
---- Data connection established
---> LIST
<--- 150 Accepted data connection
Certificate: EMAIL=ssl#p3plcpnl0953.prod.phx3.secureserver.net,CN=p3plcpnl0953.prod.phx3.secureserver.net
Issued by: EMAIL=ssl#p3plcpnl0953.prod.phx3.secureserver.net,CN=p3plcpnl0953.prod.phx3.secureserver.net
WARNING: Certificate verification: Not trusted
WARNING: Certificate verification: certificate common name doesn't match requested host name '<my_domain>.com'
gnutls_record_recv: The TLS connection was non-properly terminated. Assuming EOF.
gnutls_record_recv: The TLS connection was non-properly terminated. Assuming EOF.
**** Peer closed connection
---- Closing data socket
---- Closing control socket
---- Connecting to <my_domain>.com (160.153.92.9) port 21
<--- 220---------- Welcome to Pure-FTPd [privsep] [TLS] ----------
<--- 220-You are user number 1 of 500 allowed.
<--- 220-Local time is now 12:40. Server port: 21.
<--- 220-This is a private system - No anonymous login
<--- 220 You will be disconnected after 15 minutes of inactivity.
---> FEAT
<--- 211-Extensions supported:
<--- EPRT
<--- IDLE
<--- MDTM
<--- SIZE
<--- MFMT
<--- REST STREAM
<--- MLST type*;size*;sizd*;modify*;UNIX.mode*;UNIX.uid*;UNIX.gid*;unique*;
<--- MLSD
<--- AUTH TLS
<--- PBSZ
<--- PROT
<--- UTF8
<--- TVFS
<--- ESTA
<--- PASV
<--- EPSV
<--- SPSV
<--- ESTP
<--- 211 End.
---> AUTH TLS
<--- 234 AUTH TLS OK.
---> OPTS UTF8 ON
Certificate: EMAIL=ssl#p3plcpnl0953.prod.phx3.secureserver.net,CN=p3plcpnl0953.prod.phx3.secureserver.net
Issued by: EMAIL=ssl#p3plcpnl0953.prod.phx3.secureserver.net,CN=p3plcpnl0953.prod.phx3.secureserver.net
WARNING: Certificate verification: Not trusted
WARNING: Certificate verification: certificate common name doesn't match requested host name '<my_domain>.com'
<--- 200 OK, UTF-8 enabled
---> OPTS MLST type;size;modify;UNIX.mode;UNIX.uid;UNIX.gid;
<--- 200 MLST OPTS type;size;sizd;modify;UNIX.mode;UNIX.uid;UNIX.gid;unique;
---> USER <my_user>#<my_domain>.com
<--- 331 User <my_user>#<my_domain>.com OK. Password required
---> PASS <my_password>
<--- 230-Your bandwidth usage is restricted
<--- 230 OK. Current restricted directory is /
---> PBSZ 0
<--- 200 PBSZ=0
---> PROT P
<--- 200 Data protection level set to "private"
---> PASV
<--- 227 Entering Passive Mode (160,153,92,9,196,246)
---- Connecting data socket to (160.153.92.9) port 50422
---- Data connection established
---> LIST
<--- 150 Accepted data connection
gnutls_record_recv: The TLS connection was non-properly terminated. Assuming EOF.
**** Peer closed connection
---- Closing data socket
---- Closing control socket
---- Connecting to <my_domain>.com (160.153.92.9) port 21
<--- 220---------- Welcome to Pure-FTPd [privsep] [TLS] ----------
<--- 220-You are user number 1 of 500 allowed.
<--- 220-Local time is now 12:41. Server port: 21.
<--- 220-This is a private system - No anonymous login
<--- 220 You will be disconnected after 15 minutes of inactivity.
---> FEAT
<--- 211-Extensions supported:
<--- EPRT
<--- IDLE
<--- MDTM
<--- SIZE
<--- MFMT
<--- REST STREAM
<--- MLST type*;size*;sizd*;modify*;UNIX.mode*;UNIX.uid*;UNIX.gid*;unique*;
<--- MLSD
<--- AUTH TLS
<--- PBSZ
<--- PROT
<--- UTF8
<--- TVFS
<--- ESTA
<--- PASV
<--- EPSV
<--- SPSV
<--- ESTP
<--- 211 End.
---> AUTH TLS
<--- 234 AUTH TLS OK.
---> OPTS UTF8 ON
Certificate: EMAIL=ssl#p3plcpnl0953.prod.phx3.secureserver.net,CN=p3plcpnl0953.prod.phx3.secureserver.net
Issued by: EMAIL=ssl#p3plcpnl0953.prod.phx3.secureserver.net,CN=p3plcpnl0953.prod.phx3.secureserver.net
WARNING: Certificate verification: Not trusted
WARNING: Certificate verification: certificate common name doesn't match requested host name '<my_domain>.com'
<--- 200 OK, UTF-8 enabled
---> OPTS MLST type;size;modify;UNIX.mode;UNIX.uid;UNIX.gid;
<--- 200 MLST OPTS type;size;sizd;modify;UNIX.mode;UNIX.uid;UNIX.gid;unique;
---> USER <my_user>#<my_domain>.com
<--- 331 User <my_user>#<my_domain>.com OK. Password required
---> PASS <my_password>
<--- 230-Your bandwidth usage is restricted
<--- 230 OK. Current restricted directory is /
---> PBSZ 0
<--- 200 PBSZ=0
---> PROT P
<--- 200 Data protection level set to "private"
---> PASV
<--- 227 Entering Passive Mode (160,153,92,9,198,255)
---- Connecting data socket to (160.153.92.9) port 50943
---- Data connection established
---> LIST
<--- 150 Accepted data connection
gnutls_record_recv: The TLS connection was non-properly terminated. Assuming EOF.
**** Peer closed connection
---- Closing data socket
---- Closing control socket
---- Connecting to <my_domain>.com (160.153.92.9) port 21
<--- 220---------- Welcome to Pure-FTPd [privsep] [TLS] ----------
<--- 220-You are user number 1 of 500 allowed.
<--- 220-Local time is now 12:42. Server port: 21.
<--- 220-This is a private system - No anonymous login
<--- 220 You will be disconnected after 15 minutes of inactivity.
---> FEAT
<--- 211-Extensions supported:
<--- EPRT
<--- IDLE
<--- MDTM
<--- SIZE
<--- MFMT
<--- REST STREAM
<--- MLST type*;size*;sizd*;modify*;UNIX.mode*;UNIX.uid*;UNIX.gid*;unique*;
<--- MLSD
<--- AUTH TLS
<--- PBSZ
<--- PROT
<--- UTF8
<--- TVFS
<--- ESTA
<--- PASV
<--- EPSV
<--- SPSV
<--- ESTP
<--- 211 End.
---> AUTH TLS
<--- 234 AUTH TLS OK.
---> OPTS UTF8 ON
Certificate: EMAIL=ssl#p3plcpnl0953.prod.phx3.secureserver.net,CN=p3plcpnl0953.prod.phx3.secureserver.net
Issued by: EMAIL=ssl#p3plcpnl0953.prod.phx3.secureserver.net,CN=p3plcpnl0953.prod.phx3.secureserver.net
WARNING: Certificate verification: Not trusted
WARNING: Certificate verification: certificate common name doesn't match requested host name '<my_domain>.com'
<--- 200 OK, UTF-8 enabled
---> OPTS MLST type;size;modify;UNIX.mode;UNIX.uid;UNIX.gid;
<--- 200 MLST OPTS type;size;sizd;modify;UNIX.mode;UNIX.uid;UNIX.gid;unique;
---> USER <my_user>#<my_domain>.com
<--- 331 User <my_user>#<my_domain>.com OK. Password required
---> PASS <my_password>
<--- 230-Your bandwidth usage is restricted
<--- 230 OK. Current restricted directory is /
---> PBSZ 0
<--- 200 PBSZ=0
---> PROT P
<--- 200 Data protection level set to "private"
---> PASV
<--- 227 Entering Passive Mode (160,153,92,9,196,44)
---- Connecting data socket to (160.153.92.9) port 50220
---- Data connection established
---> LIST
<--- 150 Accepted data connection
Certificate: EMAIL=ssl#p3plcpnl0953.prod.phx3.secureserver.net,CN=p3plcpnl0953.prod.phx3.secureserver.net
Issued by: EMAIL=ssl#p3plcpnl0953.prod.phx3.secureserver.net,CN=p3plcpnl0953.prod.phx3.secureserver.net
WARNING: Certificate verification: Not trusted
WARNING: Certificate verification: certificate common name doesn't match requested host name '<my_domain>.com'
gnutls_record_recv: The TLS connection was non-properly terminated. Assuming EOF.
gnutls_record_recv: The TLS connection was non-properly terminated. Assuming EOF.
**** Peer closed connection
---- Closing data socket
---- Closing control socket
---- Connecting to <my_domain>.com (160.153.92.9) port 21
<--- 220---------- Welcome to Pure-FTPd [privsep] [TLS] ----------
<--- 220-You are user number 1 of 500 allowed.
<--- 220-Local time is now 12:44. Server port: 21.
<--- 220-This is a private system - No anonymous login
<--- 220 You will be disconnected after 15 minutes of inactivity.
---> FEAT
<--- 211-Extensions supported:
<--- EPRT
<--- IDLE
<--- MDTM
<--- SIZE
<--- MFMT
<--- REST STREAM
<--- MLST type*;size*;sizd*;modify*;UNIX.mode*;UNIX.uid*;UNIX.gid*;unique*;
<--- MLSD
<--- AUTH TLS
<--- PBSZ
<--- PROT
<--- UTF8
<--- TVFS
<--- ESTA
<--- PASV
<--- EPSV
<--- SPSV
<--- ESTP
<--- 211 End.
---> AUTH TLS
<--- 234 AUTH TLS OK.
---> OPTS UTF8 ON
Certificate: EMAIL=ssl#p3plcpnl0953.prod.phx3.secureserver.net,CN=p3plcpnl0953.prod.phx3.secureserver.net
Issued by: EMAIL=ssl#p3plcpnl0953.prod.phx3.secureserver.net,CN=p3plcpnl0953.prod.phx3.secureserver.net
WARNING: Certificate verification: Not trusted
WARNING: Certificate verification: certificate common name doesn't match requested host name '<my_domain>.com'
<--- 200 OK, UTF-8 enabled
---> OPTS MLST type;size;modify;UNIX.mode;UNIX.uid;UNIX.gid;
<--- 200 MLST OPTS type;size;sizd;modify;UNIX.mode;UNIX.uid;UNIX.gid;unique;
---> USER <my_user>#<my_domain>.com
<--- 331 User <my_user>#<my_domain>.com OK. Password required
---> PASS <my_password>
<--- 230-Your bandwidth usage is restricted
<--- 230 OK. Current restricted directory is /
---> PBSZ 0
<--- 200 PBSZ=0
---> PROT P
<--- 200 Data protection level set to "private"
---> PASV
<--- 227 Entering Passive Mode (160,153,92,9,197,243)
---- Connecting data socket to (160.153.92.9) port 50675
---- Data connection established
---> LIST
<--- 150 Accepted data connection
Certificate: EMAIL=ssl#p3plcpnl0953.prod.phx3.secureserver.net,CN=p3plcpnl0953.prod.phx3.secureserver.net
Issued by: EMAIL=ssl#p3plcpnl0953.prod.phx3.secureserver.net,CN=p3plcpnl0953.prod.phx3.secureserver.net
WARNING: Certificate verification: Not trusted
WARNING: Certificate verification: certificate common name doesn't match requested host name '<my_domain>.com'
gnutls_record_recv: The TLS connection was non-properly terminated. Assuming EOF.
gnutls_record_recv: The TLS connection was non-properly terminated. Assuming EOF.
**** Peer closed connection
---- Closing data socket
---- Closing control socket
---- Connecting to <my_domain>.com (160.153.92.9) port 21
<--- 220---------- Welcome to Pure-FTPd [privsep] [TLS] ----------
<--- 220-You are user number 1 of 500 allowed.
<--- 220-Local time is now 12:46. Server port: 21.
<--- 220-This is a private system - No anonymous login
<--- 220 You will be disconnected after 15 minutes of inactivity.
---> FEAT
<--- 211-Extensions supported:
<--- EPRT
<--- IDLE
<--- MDTM
<--- SIZE
<--- MFMT
<--- REST STREAM
<--- MLST type*;size*;sizd*;modify*;UNIX.mode*;UNIX.uid*;UNIX.gid*;unique*;
<--- MLSD
<--- AUTH TLS
<--- PBSZ
<--- PROT
<--- UTF8
<--- TVFS
<--- ESTA
<--- PASV
<--- EPSV
<--- SPSV
<--- ESTP
<--- 211 End.
---> AUTH TLS
<--- 234 AUTH TLS OK.
---> OPTS UTF8 ON
Certificate: EMAIL=ssl#p3plcpnl0953.prod.phx3.secureserver.net,CN=p3plcpnl0953.prod.phx3.secureserver.net
Issued by: EMAIL=ssl#p3plcpnl0953.prod.phx3.secureserver.net,CN=p3plcpnl0953.prod.phx3.secureserver.net
WARNING: Certificate verification: Not trusted
WARNING: Certificate verification: certificate common name doesn't match requested host name '<my_domain>.com'
<--- 200 OK, UTF-8 enabled
---> OPTS MLST type;size;modify;UNIX.mode;UNIX.uid;UNIX.gid;
<--- 200 MLST OPTS type;size;sizd;modify;UNIX.mode;UNIX.uid;UNIX.gid;unique;
---> USER <my_user>#<my_domain>.com
<--- 331 User <my_user>#<my_domain>.com OK. Password required
---> PASS <my_password>
<--- 230-Your bandwidth usage is restricted
<--- 230 OK. Current restricted directory is /
---> PBSZ 0
<--- 200 PBSZ=0
---> PROT P
<--- 200 Data protection level set to "private"
---> PASV
<--- 227 Entering Passive Mode (160,153,92,9,197,36)
---- Connecting data socket to (160.153.92.9) port 50468
---- Data connection established
---> LIST
<--- 150 Accepted data connection
gnutls_record_recv: The TLS connection was non-properly terminated. Assuming EOF.
**** Peer closed connection
---- Closing data socket
---- Closing control socket
Local Machine (working)
$ lftp -e "set ftp:ssl-force; set ssl:verify-certificate no; mirror -R --dry-run build/ / ; quit" -u <my_user>#<my_domain>.com,<my_password> ftp://<my_domain>.com --debug
mkdir -p ftp://<my_user>%40<my_domain>.com:<my_password>#<my_domain>.com/%2F
---- Connecting to <my_domain>.com (160.153.92.9) port 21
<--- 220---------- Welcome to Pure-FTPd [privsep] [TLS] ----------
<--- 220-You are user number 1 of 500 allowed.
<--- 220-Local time is now 12:27. Server port: 21.
<--- 220-This is a private system - No anonymous login
<--- 220 You will be disconnected after 15 minutes of inactivity.
---> FEAT
<--- 211-Extensions supported:
<--- EPRT
<--- IDLE
<--- MDTM
<--- SIZE
<--- MFMT
<--- REST STREAM
<--- MLST type*;size*;sizd*;modify*;UNIX.mode*;UNIX.uid*;UNIX.gid*;unique*;
<--- MLSD
<--- AUTH TLS
<--- PBSZ
<--- PROT
<--- UTF8
<--- TVFS
<--- ESTA
<--- PASV
<--- EPSV
<--- SPSV
<--- ESTP
<--- 211 End.
---> AUTH TLS
<--- 234 AUTH TLS OK.
---> OPTS UTF8 ON
Certificate: EMAIL=ssl#p3plcpnl0953.prod.phx3.secureserver.net,CN=p3plcpnl0953.prod.phx3.secureserver.net
Issued by: EMAIL=ssl#p3plcpnl0953.prod.phx3.secureserver.net,CN=p3plcpnl0953.prod.phx3.secureserver.net
WARNING: Certificate verification: Not trusted
WARNING: Certificate verification: certificate common name doesn't match requested host name ‘<my_domain>.com’
<--- 200 OK, UTF-8 enabled
---> OPTS MLST type;size;modify;UNIX.mode;UNIX.uid;UNIX.gid;
<--- 200 MLST OPTS type;size;sizd;modify;UNIX.mode;UNIX.uid;UNIX.gid;unique;
---> USER <my_user>#<my_domain>.com
<--- 331 User <my_user>#<my_domain>.com OK. Password required
---> PASS <my_password>
<--- 230-Your bandwidth usage is restricted
<--- 230 OK. Current restricted directory is /
---> PWD
<--- 257 "/" is your current location
---> PBSZ 0
<--- 200 PBSZ=0
---> PROT P
<--- 200 Data protection level set to "private"
---> PASV
<--- 227 Entering Passive Mode (160,153,92,9,198,83)
---- Connecting data socket to (160.153.92.9) port 50771
---- Data connection established
---> LIST
<--- 150 Accepted data connection
Certificate: EMAIL=ssl#p3plcpnl0953.prod.phx3.secureserver.net,CN=p3plcpnl0953.prod.phx3.secureserver.net
Issued by: EMAIL=ssl#p3plcpnl0953.prod.phx3.secureserver.net,CN=p3plcpnl0953.prod.phx3.secureserver.net
WARNING: Certificate verification: Not trusted
WARNING: Certificate verification: certificate common name doesn't match requested host name ‘<my_domain>.com’
---- Got EOF on data connection
---- Closing data socket
<--- 226-Options: -a -l
<--- 226 15 matches total
---> TYPE I
<--- 200 TYPE is now 8-bit binary
---> MDTM .
<--- 550 I can only retrieve regular files
---> MDTM ..
<--- 550 I can only retrieve regular files
---> MDTM .ftpquota
<--- 213 20160818042222
---> MDTM .htaccess
<--- 213 20151121060928
---> MDTM cgi-bin
<--- 550 I can only retrieve regular files
---> MDTM css
<--- 550 I can only retrieve regular files
---> MDTM cssinstaglam
<--- 550 I can only retrieve regular files
---> MDTM favicon.ico
<--- 213 20151003060945
---> MDTM fonts
<--- 550 I can only retrieve regular files
---> MDTM iamdev
<--- 550 I can only retrieve regular files
---> MDTM img
<--- 550 I can only retrieve regular files
---> MDTM index.html
<--- 213 20151118040443
---> MDTM less
<--- 550 I can only retrieve regular files
---> MDTM svg
<--- 550 I can only retrieve regular files
---> MDTM zoescorner.net
<--- 550 I can only retrieve regular files
get -e -O ftp://<my_user>%40<my_domain>.com:<my_password>#<my_domain>.com/ file:<local_project_path>/build/.htaccess
get -e -O ftp://<my_user>%40<my_domain>.com:<my_password>#<my_domain>.com/ file:<local_project_path>/build/favicon.ico
get -e -O ftp://<my_user>%40<my_domain>.com:<my_password>#<my_domain>.com/ file:<local_project_path>/build/index.html
mkdir ftp://<my_user>%40<my_domain>.com:<my_password>#<my_domain>.com/amp
---- CWD path to be sent is `/amp'
---> CWD /amp
<--- 550 Can't change directory to /amp: No such file or directory
get -O ftp://<my_user>%40<my_domain>.com:<my_password>#<my_domain>.com/amp file:<local_project_path>/build/amp/index.html
chmod 755 ftp://<my_user>%40<my_domain>.com:<my_password>#<my_domain>.com/amp/index.html
---- CWD path to be sent is `/cssinstaglam'
---> CWD /cssinstaglam
<--- 250 OK. Current directory is /cssinstaglam
---> TYPE A
<--- 200 TYPE is now ASCII
---> PASV
<--- 227 Entering Passive Mode (160,153,92,9,196,111)
---- Connecting data socket to (160.153.92.9) port 50287
---- Data connection established
---> LIST
<--- 150 Accepted data connection
Certificate: EMAIL=ssl#p3plcpnl0953.prod.phx3.secureserver.net,CN=p3plcpnl0953.prod.phx3.secureserver.net
Issued by: EMAIL=ssl#p3plcpnl0953.prod.phx3.secureserver.net,CN=p3plcpnl0953.prod.phx3.secureserver.net
WARNING: Certificate verification: Not trusted
WARNING: Certificate verification: certificate common name doesn't match requested host name ‘<my_domain>.com’
---- Got EOF on data connection
---- Closing data socket
<--- 226-Options: -a -l
<--- 226 10 matches total
---> TYPE I
<--- 200 TYPE is now 8-bit binary
---> MDTM .
<--- 550 I can only retrieve regular files
---> MDTM ..
<--- 550 I can only retrieve regular files
---> MDTM .include_in_version_control
<--- 213 20151003060948
---> MDTM css
<--- 550 I can only retrieve regular files
---> MDTM favicon.ico
<--- 213 20151003060948
---> MDTM img
<--- 550 I can only retrieve regular files
---> MDTM index.html
<--- 213 20151117055333
---> MDTM js
<--- 550 I can only retrieve regular files
---> MDTM less
<--- 550 I can only retrieve regular files
---> MDTM libs
<--- 550 I can only retrieve regular files
get -e -O ftp://<my_user>%40<my_domain>.com:<my_password>#<my_domain>.com/cssinstaglam file:<local_project_path>/build/cssinstaglam/favicon.ico
get -e -O ftp://<my_user>%40<my_domain>.com:<my_password>#<my_domain>.com/cssinstaglam file:<local_project_path>/build/cssinstaglam/index.html
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
<<< FILES TRANSFERED-- OMITTED FOR BREVITY >>>
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
Total: 48 directories, 299 files, 0 symlinks
New: 4 files, 0 symlinks
Modified: 295 files, 0 symlinks
To be removed: 7 directories, 5 files, 0 symlinks
---> QUIT
---- Closing control socket
I believe you have to use set ftp:ssl-force yes (you are missing the yes). This worked for me.

Changing HTTP status message using Sinatra

I'm writing a simple Sinatra app, and given a user posts a request with an specific data, I want to return an error '453' (custom error code) with a message CLIENT_ERROR, or something similar.
The problem is: looking into the Sinatra documentation and doing some testing I couldn't find a way to setup the response error message, only the response status.
So, if a set the Sinatra response
get '/' do
response.status = 453
end
I get the error code right:
curl -v localhost:4567
* About to connect() to localhost port 4567 (#0)
* Trying 127.0.0.1... connected
> GET / HTTP/1.1
> User-Agent: curl/7.22.0 (x86_64-pc-linux-gnu) libcurl/7.22.0 OpenSSL/1.0.1 zlib/1.2.3.4 libidn/1.23 librtmp/2.3
> Host: localhost:4567
> Accept: */*
>
< HTTP/1.1 453
< X-Frame-Options: sameorigin
< X-XSS-Protection: 1; mode=block
< Content-Type: text/html;charset=utf-8
< Content-Length: 0
< Connection: keep-alive
< Server: thin 1.3.1 codename Triple Espresso
<
* Connection #0 to host localhost left intact
* Closing connection #0
But what I want to have is:
< HTTP/1.1 453 CLIENT_ERROR
The same way I have
< HTTP/1.1 200 OK
When everything goes according to the plan.
Is there anyway to do this using Sinatra/Rack?
The status message is generated by the server you are using, e.g. in Thin the messages are in Thin::HTTP_STATUS_CODES and the reponse line is generated in Thin::Response, and in WEBrick they are in WEBrick::HHTPStatus::StatusMessage and the response is generated in WEBrick::HTTPResponse.
If you know what server you are using, you could add your error to the appropriate hash.
With Thin:
require 'thin'
Thin::HTTP_STATUS_CODES[453] = "Client Error"
and the output:
$ curl -v localhost:4567
* About to connect() to localhost port 4567 (#0)
* Trying 127.0.0.1... connected
* Connected to localhost (127.0.0.1) port 4567 (#0)
> GET / HTTP/1.1
> User-Agent: curl/7.19.7 (universal-apple-darwin10.0) libcurl/7.19.7 OpenSSL/0.9.8r zlib/1.2.3
> Host: localhost:4567
> Accept: */*
>
< HTTP/1.1 453 Client Error
< X-Frame-Options: sameorigin
< X-XSS-Protection: 1; mode=block
< Content-Type: text/html;charset=utf-8
< Content-Length: 0
< Connection: keep-alive
< Server: thin 1.4.1 codename Chromeo
<
* Connection #0 to host localhost left intact
* Closing connection #0
and with WEBrick:
require 'webrick'
WEBrick::HTTPStatus::StatusMessage[453] = "Client Error"
which gives the output:
$ curl -v localhost:4567
* About to connect() to localhost port 4567 (#0)
* Trying 127.0.0.1... connected
* Connected to localhost (127.0.0.1) port 4567 (#0)
> GET / HTTP/1.1
> User-Agent: curl/7.19.7 (universal-apple-darwin10.0) libcurl/7.19.7 OpenSSL/0.9.8r zlib/1.2.3
> Host: localhost:4567
> Accept: */*
>
localhost - - [13/Aug/2012:01:41:48 BST] "GET / HTTP/1.1" 453 0
- -> /
< HTTP/1.1 453 Client Error
< X-Frame-Options: sameorigin
< X-Xss-Protection: 1; mode=block
< Content-Type: text/html;charset=utf-8
< Content-Length: 0
< Server: WEBrick/1.3.1 (Ruby/1.9.3/2012-04-20)
< Date: Mon, 13 Aug 2012 00:41:48 GMT
< Connection: Keep-Alive
<
* Connection #0 to host localhost left intact
* Closing connection #0
I would recommend not to use custom HTTP status codes. If you think you have something of general use, consider writing an Internet Draft and going through the IETF specification process.

Resources