How to use a custom sftp port?

  1. When SFTP use port 22
    Create repo use restic -r

  2. When SFTP use port 2222
    Create repo use restic -r

I read doc again and again,cannot understand.
I try use restic -r

If you don’t provide the actual (full) output from the restic command, it’s going to be very hard to help you. “Fail” is not useful at all.

That said, see the text starting with “If you need to specify a port number or IPv6 address, you’ll need to use URL syntax” over in the documentation: Preparing a new repository — restic 0.13.1 documentation

The documentation is very confusing, I just want change the port 。Just give an example。Don’t mess with ipv6。

restic -r
restic -r

Result is always failed: unable to start the sftp session, error: EOF

I confirmed that the port is correct and I can link using the sftp command.

I also tried restic -r

This port is wrong,also get result failed: unable to start the sftp session, error: EOF

The output is not useful at all!

The documentation I referred you to explicitly states “If you need to specify a port number or IPv6 address, you’ll need to use URL syntax”.

It then shows an example of how to use the URL syntax. In the example the host happens to be an IPv6 address, but you can use any hostname as you please. The example also contains a port number. Please try that syntax, but with the proper hostname, et al.

Not work for me

I read the source code, sftp mode has two kinds of beginning.

  1. port modification is supported at the beginning of sftp://
  2. port modification is not supported at the beginning of sftp:

What is not working for you? Have you tried the URL syntax? If yes, exactly what did you try?

This is exactly what you have been told all along, and what the documentation states (after which it gives an example of how to use this syntax with a custom port).

Are you even reading the documentation you are being linked to?

Very confusing!

  1. sftp:// does everything perfectly, why do you need an approximation of sftp:

Point 1 is double slash, point 2 is also double slash。
The following paragraph describes the details of two /. The above is mixed with ipv6 again. Why not say one thing at a time?

Both doubleslashes are important.

The first set is required to tell the URL parser that the URL is “full form” and contains a full authority section.

The later is important to tell the underlying SFTP parser that a path from the server root is meant, rather than a relative one from the users home.

Despite being “uniform”, there is a lot of room left for interpretation, especially when used without the doubleslashes after the schema.

To answer your question, it’s simply because some fundamental understanding and familiarity with basic concepts and terminology is required to use any software, be it restic or something else.

The documentation already talks about a URL format. This means that if you don’t already understand what a URL is, you as the reader need to educate yourself on that, because it is not up to this documentation to go off on a sidetrack where it explains to the reader what a URL is and what the different parts of its format are. This is simply because a URL is such a basic, common and established concept that you are expected to understand it already, or look up if it’s an unknown thing to you. In other words, the documentation must focus on the details that are relevant for operating restic, not education of basic concepts.

Once you understand what a URL is and how it’s structured, it’s clear that when the restic documentation is talking about the “double slash”, it’s referring to the second one (in //srv in the example), and not the first one. Because it states that the double slash it’s referring to separates the connection settings from the path, this naturally means that it’s the second // it talks about (since the first // isn’t doing that same separation, so it can’t be that one).

The fact that the documentation uses an IPv6 address as the host is irrelevant because a) it clearly tells you that the [::1] part in the example is the localhost (which is a hostname, which in turn naturally means that you can replace this with whatever other hostname you want to use), and b) being familiar with what a URL is, you already know that the stuff between the first // and the :2222 is the host part, regardless of whether it’s an IPv6 address, a FQDN or an IPv4 address.

That said, I’m sure there’s room for improvement. Would you be so kind as to give a concrete suggestion on how to improve it (here or in a PR over at GitHub)? :slight_smile: