Skip to content

kalcao/ubuntu_qemu

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

26 Commits
 
 

Repository files navigation

Ubuntu On Segfault

in this repo you will know how to run Ubuntu on Segfault Server.

if you don't know this server check this https://github.com/mrx7014/SSH-KaliLinux


Let's GOOOOOO !

  • First open your server and update it
sudo apt-get update -y ; sudo apt-get upgrade -y
  • After this you should use tmate, because when you use it you will be able to use Ubuntu and Kali at the same time.

  • To use it just type tmate in terminal and copy ssh session to connect to server by it again.


  • This is some tricks to use tmate and create two tabs

  • To create a new tab of tmate use this --> ctrl + b + c

  • To move between tabs use this --> ctrl + b + "number of tab"

you will see a number of tab at bottom in the green line


  • Then enter this command on terminal to install requirements
IMAGE="ubuntu-22.04-server-cloudimg-amd64.img" ; sudo apt-get install cloud-image-utils libguestfs-tools
  • Now create .vm/ubuntu directory.
mkdir -p ~/.vm/ubuntu &>/dev/null
cd ~/.vm/ubuntu
  • Now create metadata.yaml file.
cat >metadata.yaml <<-__EOF__
instance-id: iid-${SF_HOSTNAME}01
local-hostname: ${SF_HOSTNAME}-guest
__EOF__
  • Now Create an SSH key and configure the VM. The host's /sec is shared with the VM:
[[ ! -f ~/.ssh/id_ed25519 ]] && ssh-keygen -t ed25519 -N "" -f ~/.ssh/id_ed25519 
cat >user-data.yaml <<-__EOF__
#cloud-config
users:
  - name: root
    lock_passwd: false
    hashed_passwd: '$(echo segfault | mkpasswd -m sha-512 -s)'
    ssh_authorized_keys:
      - $(cat ~/.ssh/id_ed25519.pub)
bootcmd:
  - mkdir -p /sec
mounts:
  - [ host0, /sec, 9p ]
__EOF__
cloud-localds seed.img user-data.yaml metadata.yaml
  • Install & Download cloud images:
[[ ! -f "${IMAGE}" ]] && wget "https://cloud-images.ubuntu.com/releases/jammy/release/${IMAGE}"
qemu-img resize "${IMAGE:?}" 32G
  • Now you can start using ubuntu image,but....Let's do some tricks

  • Enter this command on terminal to make a shortcut with bash script to start a image in an easy way.

cd ; touch start_ubuntu.sh ; echo "cd .vm/ubuntu ; qemu-system-x86_64 \
    -m 2G \
    -nographic \
    -device virtio-net-pci,netdev=net0 \
    -netdev user,id=net0,hostfwd=tcp::2222-:22 \
    -drive "if=virtio,format=qcow2,file=ubuntu-22.04-server-cloudimg-amd64.img" \
    -drive "if=virtio,format=raw,file=seed.img" \
    -virtfs local,path=/sec,mount_tag=host0,security_model=passthrough" >> start_ubuntu.sh ; chmod +x start_ubuntu.sh
- Note: Tag -m pointing to size of server memorey,if you have 2 GB RAM "at a usual of server keep it,And if you have more than 2GB of RAM change the number "2" to what you want
  • Now you can start a server by:
./start_ubuntu.sh
  • To stop server use halt

it will take sometime at first booting,Don't worry


  • Now after it booting and ask you about user name and password type this:

  • Username : root

  • Password : segfault

  • Now server is started.


Now let's update and setup server.

  • Now we will update and setup server for everything.

  • Just enter this command into the server

apt update ; apt install sudo ; sudo apt-get update -y ; sudo apt-get full-upgrade -y ; sudo apt install curl

Now if you facing any errors with this ubuntu version you can use DistroBox and install Ubuntu with docker via it and use Ubuntu or any other distro.


First:

  • We should install Docker.So,Enter this command in terminal
sudo apt install docker.io
  • After this install DistroBox
curl -s https://raw.githubusercontent.com/89luca89/distrobox/main/install | sudo sh
  • After installation is completed now learn how to install Ubuntu 23.04
distrobox create -i ubuntu:23.04
  • After installation is completed,Enter this command to open Ubuntu
distrobox enter ubuntu-23-04

It takes some time at the first installation.

  • After it completed you can use Ubuntu easily.

  • If you want to use another distro just type distrobox -i create <distro name:version>

Check DistroBox repo if you want to know more about it Here


  • To use /sec/root directory in ubuntu just enter:
cd /run/host/sec/root
  • if you wanna make a simple customize to server bash shell use this:
bash -c "$(curl -fsSL https://raw.githubusercontent.com/ohmybash/oh-my-bash/master/tools/install.sh)"

Contact US

About

Use QEMU to load ubuntu

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published