<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body>
Another option would be running BIND on an alternate socket, use
nsupdate to add the addresses. <br>
<br>
DNSMASQ to redirect *.mylab to the BIND instance or BIND can be run
in authoritative (for tld: "mylab.") & access restricted
recursing on socket 53.<br>
<br>
<div class="moz-cite-prefix">On 11/26/22 07:55, Geoff Back wrote:<br>
</div>
<blockquote type="cite"
cite="mid:42a0fa26-31df-74c0-69b8-b308375fe291@demonlair.co.uk">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
Hello,<br>
<br>
How about adding:<br>
<br>
alias labssh='ssh -i ~/.ssh/id_rsa.work'<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 class="moz-signature" cols="72">Geoff Back
What if we're all just characters in someone's nightmares?</pre>
<div class="moz-cite-prefix">On 26/11/2022 13:14, Feng Shao wrote:<br>
</div>
<blockquote type="cite"
cite="mid:CAJGJRzQC5Q2STnR3HBOOYRFYgazU9wYM7sBOcsm6jfQO7OWkCg@mail.gmail.com">
<meta http-equiv="content-type" content="text/html;
charset=UTF-8">
<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"
moz-do-not-send="true">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" moz-do-not-send="true">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"
moz-do-not-send="true">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" moz-do-not-send="true">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"
moz-do-not-send="true">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" moz-do-not-send="true">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>
<br>
</div>
</blockquote>
</blockquote>
<br>
</body>
</html>