Saturday, December 8, 2012

Install Archlinux on KVM, and ssh to play with it

Today, I've installed Archlinux on KVM virtual machine. I tried do it some times before but never done because the feeling something will be complicated with format HDD / config anything by hand. The truth is, it's nothing more than learn some simple command.

create a virtual machine and install archlinux on it:

root@lappy: ~ # virt-install --connect qemu:///system --name archfirst --ram 512 --disk path=~/archfirst.img,size=8 --cdrom=/home/hvn/Downloads/archlinux-2012.08.04-dual.iso


ram 512MB, 8GB HDD => that's enough for playing

follow install guide
https://wiki.archlinux.org/index.php/Beginners%27_Guide

after done, install openssh on it to ssh from host machine:
[root@hvnarch hvn]# pacman -S openssh




you have to config sshd first:
[root@hvnarch hvn]# vi /etc/ssh/sshd_config  
uncomment some line, after changed, it looks like this:
# The strategy used for options in the default sshd_config shipped with
# OpenSSH is to specify options with their default value where
# possible, but leave them commented.  Uncommented options override the
# default value.

Port 22
AddressFamily any
ListenAddress 0.0.0.0
ListenAddress ::

# The default requires explicit activation of protocol 1
Protocol 2


then enable it use systemctl :

[root@hvnarch hvn]# systemctl enable sshd.socket
[root@hvnarch hvn]# systemctl enable sshd.service



it will look like this:


[root@hvnarch hvn]# systemctl list-unit-files | grep ssh
sshd.service                           enabled
sshd@.service                          static 
sshdgenkeys.service                    static 
sshd.socket                            enabled


now, just ssh from your host machine into it.
If you want your archlinux start with your host machine, run below command:

hvn@lappy: ~ $ sudo virsh autostart archfirst

No comments: