Skip to main content
title to question
Link

ssh How to SSH from host to guest using qemuQEMU?

deleted 26 characters in body
Source Link
Michael Mrozek
  • 95.7k
  • 40
  • 245
  • 236

How do I setup ssh from the host to the guest using qemu? I am able to use port redirection when I boot the VM without any special parameters, as follows:

  1. I am able to use port redirection when I boot the VM without any special parameter(explained in point 2) as follows:

    /usr/bin/qemu-system-x86_64 -hda ubuntu1204 -m 512 -redir tcp:7777::8001

  2. But when I try to boot using the following

    /usr/bin/qemu-system-x86_64
    -m 1024
    -name vserialtest
    -hda ubuntu1204
    -chardev socket,host=localhost,port=7777,server,nowait,id=port1-char
    -device virtio-serial
    -device virtserialport,id=port1,chardev=port1-char,name=org.fedoraproject.port.0
    -net user,hostfwd=tcp:7777::8001

/usr/bin/qemu-system-x86_64 -hda ubuntu1204 -m 512 -redir tcp:7777::8001

But when I try to boot using the following:

/usr/bin/qemu-system-x86_64 \
-m 1024 \
-name vserialtest \
-hda ubuntu1204 \
-chardev socket,host=localhost,port=7777,server,nowait,id=port1-char \
-device virtio-serial \
-device virtserialport,id=port1,chardev=port1-char,name=org.fedoraproject.port.0 \
-net user,hostfwd=tcp:7777::8001

I get the following error and the VM does not boot:

qemu-system-x86_64: -net user,hostfwd=tcp:7777::8001: invalid host
forwarding rule 'tcp:7777::8001'
qemu-system-x86_64: -net user,hostfwd=tcp:7777::8001: Device 'user'
could not be initialized

Please note that I am able to boot the VM without the -net parameter without any issues, however, I want to setup ssh from the host to the guest. ssh from guest to host works fine as expected.

Edit

Edit: I I have tried using -net user,hostfwd=tcp::7777-:8001

-net user,hostfwd=tcp::7777-:8001

as well as

-net user,hostfwd=tcp::7777:8001

but still the error persists and the VM does not boot.

How do I setup ssh from the host to the guest using qemu?

  1. I am able to use port redirection when I boot the VM without any special parameter(explained in point 2) as follows:

    /usr/bin/qemu-system-x86_64 -hda ubuntu1204 -m 512 -redir tcp:7777::8001

  2. But when I try to boot using the following

    /usr/bin/qemu-system-x86_64
    -m 1024
    -name vserialtest
    -hda ubuntu1204
    -chardev socket,host=localhost,port=7777,server,nowait,id=port1-char
    -device virtio-serial
    -device virtserialport,id=port1,chardev=port1-char,name=org.fedoraproject.port.0
    -net user,hostfwd=tcp:7777::8001

I get the following error and the VM does not boot:

qemu-system-x86_64: -net user,hostfwd=tcp:7777::8001: invalid host
forwarding rule 'tcp:7777::8001'
qemu-system-x86_64: -net user,hostfwd=tcp:7777::8001: Device 'user'
could not be initialized

Please note that I am able to boot the VM without the -net parameter without any issues, however, I want to setup ssh from the host to the guest. ssh from guest to host works fine as expected.

Edit: I have tried using -net user,hostfwd=tcp::7777-:8001

as well as

-net user,hostfwd=tcp::7777:8001

but still the error persists and the VM does not boot.

How do I setup ssh from the host to the guest using qemu? I am able to use port redirection when I boot the VM without any special parameters, as follows:

/usr/bin/qemu-system-x86_64 -hda ubuntu1204 -m 512 -redir tcp:7777::8001

But when I try to boot using the following:

/usr/bin/qemu-system-x86_64 \
-m 1024 \
-name vserialtest \
-hda ubuntu1204 \
-chardev socket,host=localhost,port=7777,server,nowait,id=port1-char \
-device virtio-serial \
-device virtserialport,id=port1,chardev=port1-char,name=org.fedoraproject.port.0 \
-net user,hostfwd=tcp:7777::8001

I get the following error and the VM does not boot:

qemu-system-x86_64: -net user,hostfwd=tcp:7777::8001: invalid host
forwarding rule 'tcp:7777::8001'
qemu-system-x86_64: -net user,hostfwd=tcp:7777::8001: Device 'user'
could not be initialized

Please note that I am able to boot the VM without the -net parameter without any issues, however, I want to setup ssh from the host to the guest. ssh from guest to host works fine as expected.

Edit

I have tried using

-net user,hostfwd=tcp::7777-:8001

as well as

-net user,hostfwd=tcp::7777:8001

but still the error persists and the VM does not boot.

edited tags; edited tags
Link
Gilles 'SO- stop being evil'
  • 865.5k
  • 205
  • 1.8k
  • 2.3k
added 178 characters in body
Source Link
jobin
  • 896
  • 1
  • 8
  • 16
Loading
Source Link
jobin
  • 896
  • 1
  • 8
  • 16
Loading