35

When I try to use scp over IPv6 addresses I get this:

scp -6 osis@::1:/home/osis/test.file ./test.file
ssh: Could not resolve hostname : Name or service not known

With scp all I ever get is

ssh: Could not resolve hostname : Name or service not known

using this I get a login into my box without a hitch

ssh osis@::1

2 Answers 2

59

scp requires some special syntax. The IPv6 address must be enclosed in brackets, which must then be escaped. So in your example it would look like this:

scp -6 osis@\[2001:db8:0:1\]:/home/osis/test.file ./test.file

Otherwise the first colon ':' is thought to be the separator between the file and the address parts which would result in

ssh: Could not resolve hostname 2001: Address family for hostname not supported

In your example with the ip ::1 it is interpreted as if you want to ssh to the host '' (blank).

5
  • thank you for your answer, this info was somehow missing from man scp;man ssh
    – Osis
    Nov 22, 2010 at 14:24
  • 2
    Consider submitting an updated man page, then you can say: I helped. Nov 22, 2010 at 17:26
  • 2
    When using the -6 flag, you can just type localhost instead of ::1 (which is the IPv6 Address for localhost) to avoid the brackets and therefore any need to escape something on the shell: scp -6 osis@localhost:/home/osis/test.file ./test.file
    – freddyb
    Apr 30, 2011 at 16:22
  • 1
    You are not supposed to use IPv6 addresses, you are supposed to use DNS names.
    – Anders
    Feb 19, 2019 at 17:08
  • Note brackets work only with scp, not with ssh. Closed as WONTFIX: bugzilla.mindrot.org/show_bug.cgi?id=1602
    – MarcH
    May 15, 2020 at 23:12
2

The above command didn't work for me, the error I got was due to v6 address was allowed taking for path.

No need to use back slash "\" . As per the above example below command will work.

scp -6 osis@[2001:db8:0:1]:/home/osis/test.file ./test.file
1
  • +1 No need to use back slash "\" . As per the above example below command will work.
    – stdcerr
    Aug 17, 2021 at 22:37

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .