qemu vm setup network(ssh) with buildroot

1, build buildroot with buildroot.config, that is 'make qemu_x86_64_defconfig' + some packages, sshd, etc.
git://git.buildroot.net/buildroot

2, build kernel with alios-kvm.config, which is alios7 4.9 config + 'make kvmconfig' + 'make localyesconfig'

3, setup remap tcp port 22 to 2222, in qemu boot command, '-redir tcp:2222::22'
qemu-system-x86_64 --kernel ~/sdb/kernel-4.9/arch/x86_64/boot/bzImage
-hda ~/sdb/kernel-4.9/rootfs.ext2 -m 128G
-net nic,model=virtio -net user -redir tcp:2222::22
-append 'root=/dev/sda console=ttyS0 ' --nographic -enable-kvm

4, setup sshd in rootfs.ext2, add 'PermitRootLogin yes' in /etc/ssh/sshd_config

5, booted guest and setup ssh nokey from host to this guest
a, ssh-keygen
b, ssh-copy-id -i ~/.ssh/your_key.pub root@localhost -p 2222

6, enjoy! ssh -p 2222 root@localhost

posted @ 2018-05-23 09:37  苏小北1024  阅读(685)  评论(2编辑  收藏  举报