<div dir="ltr">Hi,<div>I am using libvirt with python binding, and I want to connect to a remote host.</div><div>I was able to connect after making ssh certificate, but It is not applicable for my project.</div><div>So I want to use openAuth() method, but I could not succeed connecting to a remote host using it.</div>
<div><br></div><div>Here is my code </div><div><span class="" style="color:rgb(51,51,51);font-family:Consolas,'Liberation Mono',Monaco,Courier,monospace;font-size:12px;line-height:18px">------------------------</span></div>
<div><span class="" style="color:rgb(51,51,51);font-family:Consolas,'Liberation Mono',Monaco,Courier,monospace;font-size:12px;line-height:18px"><br></span></div><div><span class="" style="color:rgb(51,51,51);font-family:Consolas,'Liberation Mono',Monaco,Courier,monospace;font-size:12px;line-height:18px">import </span><span style="color:rgb(85,85,85);font-family:Consolas,'Liberation Mono',Monaco,Courier,monospace;font-size:12px;line-height:18px">libvirt</span></div>
<pre style="font-family:Consolas,'Liberation Mono',Monaco,Courier,monospace;font-size:12px;margin-top:0px;margin-bottom:0px;color:rgb(51,51,51);line-height:18px"><div class="" id="LC15" style="padding-left:10px;height:18px">
<br></div><div class="" id="LC16" style="padding-left:10px;height:18px"><span class="">USER</span> <span class="" style="font-weight:bold">=</span> <span class="" style="color:rgb(221,17,68)">"root"</span></div>
<div class="" id="LC17" style="padding-left:10px;height:18px"><span class="">PASS</span> <span class="" style="font-weight:bold">=</span> <span class="" style="color:rgb(221,17,68)">"mypasswd"</span></div><div class="" id="LC18" style="padding-left:10px;height:18px">
<br></div><div class="" id="LC19" style="padding-left:10px;height:18px"><span class="" style="font-weight:bold">def</span> <span style="color:rgb(0,0,0);line-height:normal">authcb</span><span class="">(</span><span class="">credentials</span><span class="">,</span> <span class="">user_data</span><span class="">):</span><br>
</div><div class="" id="LC20" style="padding-left:10px;height:18px">    <span class="" style="font-weight:bold">for</span> <span class="">credential</span> <span class="" style="font-weight:bold">in</span> <span class="">credentials</span><span class="">:</span></div>
<div class="" id="LC21" style="padding-left:10px;height:18px">        <span class="" style="font-weight:bold">if</span> <span class="">credential</span><span class="">[</span><span class="" style="color:rgb(0,153,153)">0</span><span class="">]</span> <span class="" style="font-weight:bold">==</span> <span class="">libvirt</span><span class="" style="font-weight:bold">.</span><span class="">VIR_CRED_AUTHNAME</span><span class="">:</span></div>
<div class="" id="LC22" style="padding-left:10px;height:18px">            <span class="">credential</span><span class="">[</span><span class="" style="color:rgb(0,153,153)">4</span><span class="">]</span> <span class="" style="font-weight:bold">=</span> <span class="">USER</span></div>
<div class="" id="LC23" style="padding-left:10px;height:18px">        <span class="" style="font-weight:bold">elif</span> <span class="">credential</span><span class="">[</span><span class="" style="color:rgb(0,153,153)">0</span><span class="">]</span> <span class="" style="font-weight:bold">==</span> <span class="">libvirt</span><span class="" style="font-weight:bold">.</span><span class="">VIR_CRED_PASSPHRASE</span><span class="">:</span></div>
<div class="" id="LC24" style="padding-left:10px;height:18px">            <span class="">credential</span><span class="">[</span><span class="" style="color:rgb(0,153,153)">4</span><span class="">]</span> <span class="" style="font-weight:bold">=</span> <span class="">PASS</span></div>
<div class="" id="LC25" style="padding-left:10px;height:18px">    <span class="" style="font-weight:bold">return</span> <span class="" style="color:rgb(0,153,153)">0</span></div><div class="" id="LC26" style="padding-left:10px;height:18px">
<br></div><div class="" id="LC27" style="padding-left:10px;height:18px"><span class="">auth</span> <span class="" style="font-weight:bold">=</span> <span class="">[[</span><span class="">libvirt</span><span class="" style="font-weight:bold">.</span><span class="">VIR_CRED_AUTHNAME</span><span class="">,</span> <span class="">libvirt</span><span class="" style="font-weight:bold">.</span><span class="">VIR_CRED_PASSPHRASE</span><span class="">],</span> <span style="color:rgb(0,0,0);line-height:normal">authcb</span><span class="">,</span> <span class="" style="color:rgb(153,153,153)">None</span><span class="">]</span></div>
<div class="" id="LC28" style="padding-left:10px;height:18px"><span class="">conn</span> <span class="" style="font-weight:bold">=</span> <span class="">libvirt</span><span class="" style="font-weight:bold">.</span><span class="">openAuth</span><span class="">(</span><span class="" style="color:rgb(221,17,68)">"qemu+ssh://<a href="http://192.168.1.21/system">192.168.1.21/system</a>"</span><span class="">,</span> <span class="">auth</span><span class="">,</span> <span class="" style="color:rgb(0,153,153)">0</span><span class="">)</span></div>
<div class="" id="LC29" style="padding-left:10px;height:18px"><br></div><div class="" id="LC30" style="padding-left:10px;height:18px"><span class="" style="font-weight:bold">print</span> <span class="">conn</span><span class="" style="font-weight:bold">.getHostname()</span></div>
<div class="" id="LC30" style="padding-left:10px;height:18px"><span class="" style="font-weight:bold">-------------------------------</span></div><div class="" id="LC30" style="padding-left:10px;height:18px"><b>If there is something wrong, how am I supposed to use it.</b></div>
<div class="" id="LC30" style="padding-left:10px;height:18px"><b><br></b></div><div class="" id="LC30" style="padding-left:10px;height:18px">If its not the right place to get libvirt-python related help, from where can I get it.</div>
<div class="" id="LC30" style="padding-left:10px;height:18px"><br></div><div class="" id="LC30" style="padding-left:10px;height:18px"><br></div><div class="" id="LC30" style="padding-left:10px;height:18px">Regards</div><div class="" id="LC30" style="padding-left:10px;height:18px">
Sijo</div><div class="" id="LC30" style="padding-left:10px;height:18px"><span class="" style="font-weight:bold"><br></span></div><div class="" id="LC30" style="padding-left:10px;height:18px"><span class="" style="font-weight:bold"><br>
</span></div><div class="" id="LC30" style="padding-left:10px;height:18px"><span class="" style="font-weight:bold"><br></span></div><div class="" id="LC30" style="padding-left:10px;height:18px"><span class="" style="font-weight:bold"><br>
</span></div></pre><div><br></div></div>