<div dir="ltr">Aha! This indeed meets my requirements exactly! In my case I also added '-l root' to alias.<div><br></div><div>Thank you!</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Sat, Nov 26, 2022 at 10:36 PM Geoff Back <<a href="mailto:geoff@demonlair.co.uk">geoff@demonlair.co.uk</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<div>
Hello,<br>
<br>
How about adding:<br>
<br>
alias labssh='ssh -i ~/.ssh/<a href="http://id_rsa.work" target="_blank">id_rsa.work</a>'<br>
<br>
to your shell profile (.bashrc or whatever)? Then you can just do
'labssh <ip-address>' and the alias expansion makes ssh use
the appropriate ID file.<br>
<br>
Regards,<br>
<br>
Geoff.<br>
<br>
<pre cols="72">Geoff Back
What if we're all just characters in someone's nightmares?</pre>
<div>On 26/11/2022 13:14, Feng Shao wrote:<br>
</div>
<blockquote type="cite">
<div>
<div dir="auto">Thanks for the reply Petr.</div>
<div dir="auto">Let me explain more about the motivation: I am a
developer and our testers test the code on various
environments, including VMs on cloud and k8s worker nodes from
cloud providers. These machines and IPs are not
provisioned/allocated by dnsmasq. For cost reason, these
environments only lives for a short period of time, like one
week or so, and testers provision these IPs directly without
awareness of network administrators, that’s also why we don’t
configure hostname for these machines in DNS system. Also I
can not know in advance the list of possible IPs.</div>
<div dir="auto"><br>
</div>
<div dir="auto">Whenever tester find some issue or need help,
they give me the IP of the environments and I need to ssh to
that environment. Because I will probably login to that same
machine several times since the testers are testing my code on
that machine recently, I want to setup passwordless login. So
I normally ssh-copy-id -i <~/.ssh/<a href="http://id_rsa.work" target="_blank">id_rsa.work</a>> <IP>first,
then ssh to that machine. In order to instruct ssh to use my
ssh key when connecting to that IP, I have below lines in my
.ssh/config:</div>
</div>
<div>
<div dir="auto"><span style="word-spacing:1px;border-color:rgb(49,49,49);color:rgb(49,49,49)"><br>
</span></div>
<div dir="auto"><span style="word-spacing:1px;border-color:rgb(49,49,49);color:rgb(49,49,49)">Host
*.mylab</span></div>
<div dir="auto"><span style="word-spacing:1px;border-color:rgb(49,49,49);color:rgb(49,49,49)">
User root</span></div>
<div dir="auto"><span style="word-spacing:1px;border-color:rgb(49,49,49);color:rgb(49,49,49)">
IdentityFile ~/.ssh/</span><a href="http://id_rsa.work/" style="font-size:1rem;word-spacing:1px;border-color:rgb(66,133,244)" target="_blank">id_rsa.wor</a>k</div>
<div dir="auto"><br>
</div>
</div>
<div>
<div dir="auto">And lines like below in /etc/hosts:</div>
<div dir="auto"><span style="word-spacing:1px;border-color:rgb(49,49,49);color:rgb(49,49,49)">address=/<a href="http://123.123.123.123" style="border-color:rgb(66,133,244)" target="_blank">123.123.123.123</a>.</span><span style="word-spacing:1px;border-color:rgb(49,49,49);color:rgb(49,49,49)">mylab/</span><a href="http://123.123.123.123/" style="font-size:1rem;word-spacing:1px;border-color:rgb(66,133,244)" target="_blank">123.123.123.123</a></div>
<div dir="auto"><span style="word-spacing:1px;border-color:rgb(49,49,49);color:rgb(49,49,49)">address=/<a href="http://123.123.123.123" style="border-color:rgb(66,133,244)" target="_blank">123.123.123.12</a>4.</span><span style="word-spacing:1px;border-color:rgb(49,49,49);color:rgb(49,49,49)">mylab/</span><a href="http://123.123.123.123/" style="font-size:1rem;word-spacing:1px;border-color:rgb(66,133,244)" target="_blank">123.123.123.12</a>4<br>
</div>
<div dir="auto"><br>
</div>
<div dir="auto">So that I can now “ssh 123.123.123.123.mylab” </div>
<div dir="auto"><br>
</div>
<div dir="auto">As you can see, the problem here is, whenever a
new IP comes, I need to add a new entry in /etc/hosts. So what
I want is any <IP>.mylab is resolved to <IP>.</div>
<div dir="auto"><br>
</div>
<div dir="auto">A key pair can be specified when creating VM on
cloud, but I can not ask every tester add my ssh key pair when
creating VM.</div>
<div dir="auto"><br>
</div>
<div dir="auto"><br>
</div>
<div>
<div class="gmail_quote">
<div dir="ltr" class="gmail_attr">Petr Menšík <<a href="mailto:pemensik@redhat.com" target="_blank">pemensik@redhat.com</a>>于2022年11月25日
周五19:52写道:<br>
</div>
</div>
</div>
</div>
<div>
<div>
<div class="gmail_quote">
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<div>
<p>Did you know that dnsmasq registers all hosts by
their name, if they send their own hostname when
requesting DHCP from dnsmasq? Just use domain=mylab
and have that host send hostname. It would make using
names possible without any additional configuration.<br>
</p>
<p>I do not get what is the advantage of having IP
suffixed by some domain. It looks like IP address, but
it is even longer. Names of machines should be easy to
remember or use, I doubt that would be the case here.</p>
<p>I think we have new feature conf-script, which can
generate dnsmasq configuration on the output. But I
doubt we have a possible code for what you describe.
Could you please describe more about intended usage?
Why isn't using just hostname for each host enough?
Using dhcp-host seems enough for similar uses.<br>
</p>
<p>I think DLZ plugins for BIND9 are able to do similar
things to your request, but that would be very
heavy-weight solution. I think more motivation for
your current design should be shared, because I do not
understand advantage of your solution.</p>
<p>Cheers,<br>
Petr<br>
</p>
</div>
<div>
<div>On 11/23/22 06:47, Feng Shao wrote:<br>
</div>
</div>
<div>
<blockquote type="cite"> <span style="word-spacing:1px;color:rgb(49,49,49)">There
are a bunch of machines in our lab, and we normally
don't have DNS records configured for them, only
accessing by IP. In order to ssh to them with key
auth, I have a config in my .ssh/config like </span><br style="color:rgb(49,49,49);word-spacing:1px">
<br style="color:rgb(49,49,49);word-spacing:1px">
<span style="word-spacing:1px;color:rgb(49,49,49)">Host
*.mylab</span><br style="color:rgb(49,49,49);word-spacing:1px">
<span style="word-spacing:1px;color:rgb(49,49,49)">
User root</span><br style="color:rgb(49,49,49);word-spacing:1px">
<span style="word-spacing:1px;color:rgb(49,49,49)">
IdentityFile ~/.ssh/</span><a href="http://id_rsa.work/" style="font-size:1rem;word-spacing:1px" target="_blank">id_rsa.work</a><br style="color:rgb(49,49,49);word-spacing:1px">
<br style="color:rgb(49,49,49);word-spacing:1px">
<span style="word-spacing:1px;color:rgb(49,49,49)">and
I have some "address=/<a href="http://123.123.123.123" target="_blank">123.123.123.123</a>.</span><span style="word-spacing:1px;color:rgb(49,49,49)">mylab/</span><a href="http://123.123.123.123/" style="font-size:1rem;word-spacing:1px" target="_blank">123.123.123.123</a><span style="word-spacing:1px;color:rgb(49,49,49)">" line
in dnsmasq.conf. The problem here is I need to add
an entry whenever a new IP comes.</span><br style="color:rgb(49,49,49);word-spacing:1px">
<br style="color:rgb(49,49,49);word-spacing:1px">
<span style="word-spacing:1px;color:rgb(49,49,49)">Can
this configuration be dynamically? For example,
"address=/*.mylab/somecmd %1", where "somecmd" is a
external command and %1 will be replaced by the name
in A/AAAA request. So that for any DNS request to
*.mylab, dnsmasq invoke this external command and
pass the name as argument, the output of external
command, which will be interpreted as IPv4/IPv6 addr
then responsed to client?</span> <br>
<fieldset></fieldset>
</blockquote>
</div>
<div>
<blockquote type="cite">
<pre style="font-family:monospace">_______________________________________________
Dnsmasq-discuss mailing list
<a href="mailto:Dnsmasq-discuss@lists.thekelleys.org.uk" style="font-family:monospace" target="_blank">Dnsmasq-discuss@lists.thekelleys.org.uk</a>
<a href="https://lists.thekelleys.org.uk/cgi-bin/mailman/listinfo/dnsmasq-discuss" style="font-family:monospace" target="_blank">https://lists.thekelleys.org.uk/cgi-bin/mailman/listinfo/dnsmasq-discuss</a>
</pre>
</blockquote>
</div>
<div>
<blockquote type="cite"> </blockquote>
<pre cols="72" style="font-family:monospace">--
Petr Menšík
Software Engineer, RHEL
Red Hat, <a href="https://www.redhat.com/" style="font-family:monospace" target="_blank">https://www.redhat.com/</a>
PGP: DFCF908DB7C87E8E529925BC4931CA5B6C9FC5CB</pre>
</div>
_______________________________________________<br>
Dnsmasq-discuss mailing list<br>
<a href="mailto:Dnsmasq-discuss@lists.thekelleys.org.uk" target="_blank">Dnsmasq-discuss@lists.thekelleys.org.uk</a><br>
<a href="https://lists.thekelleys.org.uk/cgi-bin/mailman/listinfo/dnsmasq-discuss" rel="noreferrer" target="_blank">https://lists.thekelleys.org.uk/cgi-bin/mailman/listinfo/dnsmasq-discuss</a><br>
</blockquote>
</div>
</div>
</div>
<br>
<fieldset></fieldset>
<pre>_______________________________________________
Dnsmasq-discuss mailing list
<a href="mailto:Dnsmasq-discuss@lists.thekelleys.org.uk" target="_blank">Dnsmasq-discuss@lists.thekelleys.org.uk</a>
<a href="https://lists.thekelleys.org.uk/cgi-bin/mailman/listinfo/dnsmasq-discuss" target="_blank">https://lists.thekelleys.org.uk/cgi-bin/mailman/listinfo/dnsmasq-discuss</a>
</pre>
</blockquote>
<br>
</div>
_______________________________________________<br>
Dnsmasq-discuss mailing list<br>
<a href="mailto:Dnsmasq-discuss@lists.thekelleys.org.uk" target="_blank">Dnsmasq-discuss@lists.thekelleys.org.uk</a><br>
<a href="https://lists.thekelleys.org.uk/cgi-bin/mailman/listinfo/dnsmasq-discuss" rel="noreferrer" target="_blank">https://lists.thekelleys.org.uk/cgi-bin/mailman/listinfo/dnsmasq-discuss</a><br>
</blockquote></div>