# SSH to literal IPv6 address

**URL:** <https://forum.ansible.com/t/ssh-to-literal-ipv6-address/23659>\
**Category:** Ansible Project\
**Created:** [February 7, 2017, 9:38am UTC](https://forum.ansible.com/t/ssh-to-literal-ipv6-address/23659 "2017-02-07T09:38:52Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Dick\_Visser](https://avatars.discourse-cdn.com/v4/letter/d/d9b06d/32.png) [@Dick\_Visser](https://forum.ansible.com/u/Dick_Visser)\
**Post date:** [February 7, 2017, 9:38am UTC](https://forum.ansible.com/t/ssh-to-literal-ipv6-address/23659/1 "2017-02-07T09:38:52Z")

</div>

Hi

I'm trying to set up a quick test host and have added this entry in my  
~/.ssh/config:

# Test host  
Host imapsync  
&nbsp;&nbsp;Hostname 2001:610:148:f00d:20c:29ff:fe14:ccfe

Just issuing "ssh imapsync" works fine.

I have this corresponding in my ansible inventory:

# test host  
imapsync

But when I try to run "ansible imapsync -m setup", I get:

"SSH Error: data could not be sent to the remote host. Make sure this  
host can be reached over ssh".

It turns out that the literal IPv6 address is the culprit.  
If I enable IPv4 on the host and change the ssh config to:

# Test host  
Host imapsync  
&nbsp;&nbsp;Hostname 192.87.38.66

Then things work.

Is there another way of specifying a literal IPv6 address.

PS I also tested using DNS by adding the name to /etc/hosts, and that  
seems to work as well.  
But the whole point of having ssh config's "Hostname" and ansible's  
inventory is to no use DNS.

Thanks!

---

<div class="post-metadata">

**Author:** ![Johannes\_Kastl](https://avatars.discourse-cdn.com/v4/letter/j/bbe5ce/32.png) [@Johannes\_Kastl](https://forum.ansible.com/u/Johannes_Kastl)\
**Post date:** [February 7, 2017, 10:24am UTC](https://forum.ansible.com/t/ssh-to-literal-ipv6-address/23659/2 "2017-02-07T10:24:17Z")

</div>

I thought ssh needed IPv6 addresses in square brackets (to avoid  
confusion with ports added as suffix)?

Host imapsync  
&nbsp;&nbsp;&nbsp;Hostname [2001:610:148:f00d:20c:29ff:fe14:ccfe]

Johannes

---

<div class="post-metadata">

**Author:** ![Dick\_Visser](https://avatars.discourse-cdn.com/v4/letter/d/d9b06d/32.png) [@Dick\_Visser](https://forum.ansible.com/u/Dick_Visser)\
**Post date:** [February 7, 2017, 11:23am UTC](https://forum.ansible.com/t/ssh-to-literal-ipv6-address/23659/3 "2017-02-07T11:23:38Z")

</div>

Nope that doesn't work, neither in .ss/config nor on the command line.  
You need the Port option, or -p on the command line.

The bracket notation isn't used by OpenSSH.

I know that for web browsers the brackets are mandatory when using  
IPv6 literals.

---

<div class="post-metadata">

**Author:** ![Johannes\_Kastl](https://avatars.discourse-cdn.com/v4/letter/j/bbe5ce/32.png) [@Johannes\_Kastl](https://forum.ansible.com/u/Johannes_Kastl)\
**Post date:** [February 7, 2017, 11:34am UTC](https://forum.ansible.com/t/ssh-to-literal-ipv6-address/23659/4 "2017-02-07T11:34:29Z")

</div>

As a workaround, what happens if you append the port?

Host imapsync  
&nbsp;&nbsp;&nbsp;&nbsp;Hostname [2001:610:148:f00d:20c:29ff:fe14:ccfe]:22

This should be valid ssh syntax, at least I have some of those in my  
config or known\_hosts.

Johannes

---

<div class="post-metadata">

**Author:** ![Dick\_Visser](https://avatars.discourse-cdn.com/v4/letter/d/d9b06d/32.png) [@Dick\_Visser](https://forum.ansible.com/u/Dick_Visser)\
**Post date:** [February 7, 2017, 12:13pm UTC](https://forum.ansible.com/t/ssh-to-literal-ipv6-address/23659/5 "2017-02-07T12:13:04Z")

</div>

It doesn't work here:

~$ ssh imapsync  
ssh: Could not resolve hostname  
[2001:610:148:f00d:20c:29ff:fe14:ccfe]:22: nodename nor servname  
provided, or not known

This is on MacOS using OpenSSH\_7.3p1, LibreSSL 2.4.1.  
But I just tried on an Ubuntu box (OpenSSH\_7.2p2 Ubuntu-4ubuntu2.1,  
OpenSSL 1.0.2g 1 Mar 2016) and the same result there.

Not a show stopper but I'd like to avoid using scarce IPv4 addresses.

Dick

---

<div class="post-metadata">

**Author:** ![Johannes\_Kastl](https://avatars.discourse-cdn.com/v4/letter/j/bbe5ce/32.png) [@Johannes\_Kastl](https://forum.ansible.com/u/Johannes_Kastl)\
**Post date:** [February 7, 2017, 12:21pm UTC](https://forum.ansible.com/t/ssh-to-literal-ipv6-address/23659/6 "2017-02-07T12:21:14Z")

</div>

Sorry, my mistake, those were not in Hostname declarations.

I do not have a ipv6 host handy, so I can't test...

Johannes

---

<div class="post-metadata">

**Author:** ![Kai\_Stian\_Olstad](https://avatars.discourse-cdn.com/v4/letter/k/e19adc/32.png) [@Kai\_Stian\_Olstad](https://forum.ansible.com/u/Kai_Stian_Olstad)\
**Post date:** [February 7, 2017, 6:27pm UTC](https://forum.ansible.com/t/ssh-to-literal-ipv6-address/23659/7 "2017-02-07T18:27:43Z")

</div>

Just for fun I tested this, it work for me.  
I'm running Ansible 2.1.2 at the moment.

---

<div class="post-metadata">

**Author:** ![Dick\_Visser](https://avatars.discourse-cdn.com/v4/letter/d/d9b06d/32.png) [@Dick\_Visser](https://forum.ansible.com/u/Dick_Visser)\
**Post date:** [February 7, 2017, 7:21pm UTC](https://forum.ansible.com/t/ssh-to-literal-ipv6-address/23659/8 "2017-02-07T19:21:48Z")

</div>

Just check the output of -vvvvv and ran the same command in a shell:

dick.visser@MacBookAir-DIck:~$ ssh -C -o ControlMaster=auto -o  
ControlPersist=60s -o KbdInteractiveAuthentication=no -o  
PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey  
-o PasswordAuthentication=no -o ConnectTimeout=20 -o  
ControlPath=/Users/dick.visser/.ansible/cp/ansible-ssh-%h-%p-%r  
imapsync  
unix\_listener: "/Users/dick.visser/.ansible/cp/ansible-ssh-2001:610:148:f00d:20c:29ff:fe14:ccfe-22-visser.yQ7UwntkXwvGTUmk"  
too long for Unix domain socket

After using the hint from  
[http://docs.ansible.com/ansible/intro\_configuration.html#control-path](http://docs.ansible.com/ansible/intro_configuration.html#control-path)  
things started working.

Dick
