Welcome!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!

Syntax for SFTP Data in FTP.CFG File

Jun
564
4
I have successfully made regular FTP connections from the command line with explicit connection data and with data obtained via the FTP.CFG file, but I cannot get SFTP connections to work. What is the proper form for the entry in the FTP.CFG file, and what is the syntax to use that connect data from the command line (e.g., for DIR and IFTP)?

I got an IFTP command to work once, but now it always fails. I have tried the following:

Code:
     iftp /P1 sftp://user:pw@host:22
     iftp /P1 "sftp://user:pw@host:22"  [because the pw contains percent signs and carets]


For those I get the error message, "TCC: [10053] Software caused connection abort "host". For various other attempts, I get some long message after a long timeout.
 
A search for SFTP in this forum produced quite a few hits.

Take a look at the search results and see if anything helps your situation.

Also, what version of Windows and TCC are you using?
(your signature notes v27 and v25)

In one of the messages, @rconn talked of a problem with the IPWorks dll.

Has that been fixed in your version of TCC?

ADDED: It looks like v25.00.20 x64 was the version that had problems with the IPWorks dll.

Joe
 
Ordinarily, I use version 27, though I still have version 25 on my computer. The Windows version is in my signature line.

The problem may be related to the status of the server's host key. I was able to set up a connection once with IFTP, but after that I could never get it to work again, even using the latest FileZilla. I'm wondering if something may have rejected the host key, thereby blocking further access.

It would be nice if the TCC documentation had more examples of FTP.CFG entries.

I will try the search you suggested.

Jay
 
I think that I have figured out part of the problem. My password contains some special characters, such as the percent sign. When I used "IFTP /=" to enter the data, it worked. FileZilla worked once, too. However, when I started experimenting with command-line access, the special characters messed up the password (as my attempts to 'escape' the special characters failed), and the server eventually locked me out for excessive password failures.

I have asked the admin to change my password to something without those problematic special characters, and then I can experiment some more.

This still leaves the question as to what the proper entries should be in the FTP.CFG file for FTPS and SFTP access and what the proper command-line access should be. (My guesses were probably correct but failed because of the password problem.) Nevertheless, it would be nice if the help file contained some examples for sites other than plain FTP sites.
 
After waiting a few days, my access to the site has been unlocked, and FileZilla logs in just fine.

That leaves me the question, which I hope someone can answer, as to what the entry needs to be in FTP.CFG when a password (or username) contains special characters. Does one need to escape anything, or are strings used literally? I believe that when I used IFTP with the /= option to enter the information, things worked OK, so the data must have been passed without interpretation of special characters. I imagine that whenever the information is entered on the command line, special modifications are required.

The special characters that have been messing things up for me are: %^*. So, for example, a password of "a%b*x^cd" (without the quotes) caused a lot of problems, even the asterisk, perhaps erroneously because of its special meaning when it is the sole character in the password to ask to be prompted.

I tried entering the password with the following changes, but that seemed not to work: "a%%b^*x^^cd".

Then there is the general question that I asked about how an sftp connection should be recorded in the FTP.CFG (or does that file work only for FTP connections and not SSH connections?).
 
Hmmm! I can't test sftp, but for normal ftp, this (no special character handling) worked. I don't imagine TCC's handling of entries in FTP.CFG would depend of the protocol. You can try normal FTP to vefatica.net as the user "test"; he is locked in the root directory and has only READ permission.

Here's the server setup.

1680485689761.png


Here's FTP.CFG.

Code:
d:\tc29> type ftp.cfg
ftp://vefatica.net test a%b^c*d

Here's what I tried the result.

Code:
d:\tc29> dir ftp://vefatica.net

 Directory of  ftp://vefatica.net/*

2022-12-02  21:22         <DIR>    4plugins
2022-07-26  00:00         <DIR>    experimental
2014-08-08  00:00       3,657,325  arnex4.JPG
2022-08-30  00:00         120,245  pset3264.zip
2023-03-15  21:19          74,062  rundown.zip
2021-02-17  00:00          45,706  shellex.zip
           3,897,338 bytes in 4 files and 2 dirs

And here's a clip from the server's log.

Code:
[02] Sun 02Apr23 21:36:21 - (000069) Connected to 192.168.1.1 (local address 192.168.1.151, port 21)
[02] Sun 02Apr23 21:36:21 - (000069) User "test" logged in
[02] Sun 02Apr23 21:36:21 - (000069) User "test" logged out
[02] Sun 02Apr23 21:36:21 - (000069) Closed session
 
That (above) seems to work with SFTP also.

Code:
d:\tc29> dir sftp://vefatica.net
The server provided the following fingerprint:
  a7:01:3e:77:c4:87:78:31:28:5d:38:23:0e:ac:8b:70:9f:67:9f:2d:5e:e3:7c:77:34:6e:bf:00:60:1a:e7:45

 Directory of  sftp://vefatica.net/*

2022-12-03  01:22         <DIR>    4plugins
2022-07-27  00:00         <DIR>    experimental
2014-08-08  00:00       3,657,325  arnex4.JPG
2022-08-30  00:00         120,245  pset3264.zip
2023-03-16  01:19          74,062  rundown.zip
2021-02-18  00:00          45,706  shellex.zip
           3,897,338 bytes in 4 files and 2 dirs
 
Thanks. So it looks as though the characters in FTP.CFG are taken literally and that nothing needs to be done for special characters.

After you set up that password, did you try accessing the server from the command line? I doubt that the following would have worked:

type ftp://test:a%b^c*[email protected]

You presumably would have had to escape some of the characters. I made a number of failed attempts with the server access that the person set up for me. Of course, I probably got locked out after a few failures, so it didn't work even when I got the command line right. I'm a bit gun-shy about experimenting further with that site. Perhaps I could do what you did: set up a site on my own server with that password containing special characters.

I asked to have my password changed to something without any of the TCC special characters, but the person in charge is not being helpful. He thinks I should just do things his way (using FileZilla). Since I will probably use that server once in a year but use TCC to access servers constantly, I'm not likely to remember. He may find that I just decide not to bother updating my page on his site.
 
OK. I just did some experimenting. I first researched how to access my own servers using SSH (I've used only FTP in the past). My passwords have no characters that TCC interprets, and I got things working. Then I put the following line into FTP.CFG for the problem server:

sftp://server_url (alias) user password

The user and password were what I was given, including the special characters.

Now I was able to run the following commands:

dir sftp://alias/ dir sftp://alias dir sftp://alias/*.jpg

and they worked just fine.
 
I'd expect to need normal escaping to be required on the command line.

Code:
v:\> echo foo > d:\anonymous\foo.txt

v:\> type ftp://test:a%%b^^c*[email protected]/foo.txt
foo

But that does't work for SFTP. Maybe TYPE doesn't support SFTP.
 
Two things. For SFTP you have to start with sftp:// rather than ftp://. Also, I think (at least for version 27) that the asterisk is a special character. This is based on the error messages I received when my commands were rejected. The percent sign and caret disappeared, and the asterisk also disappeared. It made me suspect a bug in the code for triggering prompting for the password.

I think that from now on I'm going to put everything into FTP.CFG, since that avoids all the problems with special characters, and the alias feature lets me use short names for the logins.
 
AFAICT, whatever works in v29 also works in v27. All of what's below is the same in v29 and v27. Today the setup is this.

Code:
ftp://vefatica.net (alias) test a%b^c*d

Some things seem to work using the alias, some don't ... both FTP and SFTP. It seems to be a bit of a mess. Here's FTP.

Code:
v:\> dir ftp://alias/*.txt

 Directory of  ftp://alias/*.txt

2023-04-03  14:10               5  foo.txt
                   5 bytes in 1 file and 0 dirs

v:\> type ftp://alias/*.txt
TCC: (Sys) No such host is known.
 "ftp://alias/foo.txt"

v:\> type ftp://vefatica.net/foo.txt
foo

And here's SFTP. Notice how the first TYPE below leaves the connection open (verified at the server) even though the connection appeared to fail.

Code:
v:\> dir sftp://alias/*.txt

 Directory of  sftp://alias/*.txt

2023-04-03  18:10               5  foo.txt
                   5 bytes in 1 file and 0 dirs

v:\> type sftp://alias/*.txt
TCC: The RemoteHost address is invalid (0.0.0.0). "sftp://alias/foo.txt"

v:\> type sftp://vefatica.net/foo.txt
TCC: Already connected. If you want to reconnect, close the current connection first. "vefatica.net"
TCC: The RemoteHost address is invalid (0.0.0.0). "sftp://vefatica.net/foo.txt"
 
That is odd. I have only displayed directory contents, copied or moved files, or deleted files. I never tried to work on them directly, such as with the TYPE command.

Does TYPE work with the full command-line syntax rather than the alias?

Ah, I think I discovered what is going wrong. The problem is the issue of forward slash vs backward slash for separators. Sometimes, but not always, it is essential to enclose the target in quotation marks. The following command works:

type "ftpsagemail:jay/mailbox.sieve"

Without the quotation marks, I get a "parameter is incorrect" error message.

I have another directory alias

ftpsagemailj=ftpsagemail:jay/

The following command works fine:

type ftpsagemailj:mailbox.sieve

The problem arises when there is an unquoted forward slash in the command line. TCC thinks it is an option switch. It may be best to always quote the command when it is going to a Unix server.
 
Further development: The last command above stopped working when I redefined ftpsagemail: to use an alias. I thought I had changed all of them to use alias references, but I had missed that one.

Oddly, the command referencing the alias works fine with the full command (rather than the directory alias):

dir ftp://sagemail/jay/

Even the following works without quotation marks (and displayed the one file):

dir ftp://sagemail/jay/mailbox.sieve

but the following reports "no such host is known":

type ftp://sagemail/jay/mailbox.sieve

It doesn't work even when quoted.

My head is hurting! I think I better leave this alone for a bit.
 
I would raise your attention to the fact that SFTP is not related to FTP in any way, shape or form. SFTP is a subcommand of SSH.
 
I would raise your attention to the fact that SFTP is not related to FTP in any way, shape or form. SFTP is a subcommand of SSH.

Indeed, but TCC handles both FTP and SSH from the command line using similar syntax and from the FTP.CFG file.
 

Similar threads

Back
Top