<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On 5 January 2013 12:29, Alan McDuff <span dir="ltr"><<a href="mailto:alan.mcduff@yahoo.com" target="_blank">alan.mcduff@yahoo.com</a>></span> wrote:<br>

<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div><div style="font-size:12pt;font-family:times new roman,new york,times,serif"><div class="im">>If you paste the .lxc part from <a href="http://www.stgraber.org/2012/07/17/easily-ssh-to-your-containers-and-vms-on-ubuntu-12-04-lts/" target="_blank">http://www.stgraber.org/2012/07/17/easily-ssh-to-your-containers-and-vms-on-ubuntu-12-04-lts/</a> into your ~/.ssh/config >and start the container, then you should be able to ssh with "ssh ubuntu@guest1.lxc".</div>

<div style="font-family:times new roman,new york,times,serif;font-size:12pt"><div style="font-family:times new roman,new york,times,serif;font-size:12pt"><br>Thanks, but this doesn't look like a clean setup to me. If there is no better solution, I will write a post-lxc-create script that appends "$(host $guestname 10.0.3.1) $guestname" to /etc/hosts.<br>

</div></div></div></div></blockquote><div><br></div><div>I think that writing the address into /etc/hosts may cause you problems eventually because it will get out of date when you remove containers and potentially recycle addresses.<br>

<br></div><div>Stephane's solution has the advantage that it looks up the address dynamically when you need it. I really like the idea of putting the look-up into ~/.ssh/config, especially because it allows you to other useful things like turning off some security checking and setting the username.<br>

<br>If you don't like that solution because of the non-locality, you might prefer to write a small script, say `lxc-ssh`:<br><br></div><div>    $1=container<br></div><div>    ssh $(host $container 10.0.3.1 | tail -1 | awk '{print $NF}')</div>

</div><br></div><div class="gmail_extra">-Ben<br><br></div></div>