title: How to connect KVM guest vm from mac hosts by ssh?
body: <p>I want to use KVM on Macbook. So what I did to start the kvm is:</p>
  <pre class="lang-sh prettyprint-override"><code>qemu-system-x86_64 -m 2G ./bastion-rhel7.qcow2 -accel hvf
  </code></pre>
  <p>The VM starts ok. But I can't ssh root@10.0.2.15 which is the default vm network interface.
  it only contains a default vm interface, looks like this:</p>
  <pre><code>1: lo: &lt;LOOPBACK,UP,LOWER_UP&gt; mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
      link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
      inet 127.0.0.1/8 scope host lo
         valid_lft forever preferred_lft forever
      inet6 ::1/128 scope host
         valid_lft forever preferred_lft forever
  2: ens3: &lt;BROADCAST,MULTICAST,UP,LOWER_UP&gt; mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
      link/ether 52:54:00:12:34:56 brd ff:ff:ff:ff:ff:ff
      inet 10.0.2.15/24 brd 10.0.2.255 scope global noprefixroute dynamic ens3
         valid_lft 86353sec preferred_lft 86353sec
      inet6 fec0::caa4:e2ac:1cf9:230e/64 scope site noprefixroute dynamic
         valid_lft 86354sec preferred_lft 14354sec
      inet6 fe80::393b:a23c:2981:6282/64 scope link noprefixroute
         valid_lft forever preferred_lft forever
  </code></pre>
  <p>After read <a href="https://superuser.com/questions/1326255/virtualbox-macos-host-cannot-connect-to-guest-but-guest-can-connect-to-host">this article</a>, I know I can attach host-only network if I use virtualbox to fix this problem.</p>
  <p>It makes me that if I can attach host-only network for KVM from qemu-system_x86_64 commandline, then I can ssh to my kvm guest. But I don't know how or if this is feasible for kvm.</p>
  <p>I appreciate any comments and solutions, all I want to do is to connect the guest vm via ssh from mac hosts.</p>
  <p>(My macbook only have wifi connection, so I <em>think</em> &quot;bridge&quot; mode is not an option to me.)</p>