Making Use of the HowtoForge .ova File in VirtualBox

Discussion in 'HOWTO-Related Questions' started by yupthatguy, May 11, 2021.

Tags:
  1. yupthatguy

    yupthatguy Member HowtoForge Supporter

    Prerequisites:
    • You have doanted the $25 to ISPConfig & have downloaded the .ova file for your selected tutorial to your local machine
    • You have Virtualbox 6.1 installed on your host machine

    1.) Launch Virtualbox6.1 & from "File" menu select "Import Appliance" (or Ctrl + I)
    **Navigate to your .ova file, select it, and click "open", then click "Next" in the "Import Virtual Appliance"

    2.) On the "Appliance Settings" screen that appears (screenshot 1), you can make whatever changes you want to the new guest machine prior to importing it. I recommend, initially just changing the name on the guest machine from "vm" to something more descriptive & changing the Guest OS type to match your selected tutorial (if it doesn't already match). When you are happy with your settings click "import".

    NOTE: If the OS type does not match you may downloaded the wrong .ova file, double-check :)

    screenshot 1
    [​IMG]

    3.) Once you have successfully imported the virtual machine, go ahead and start the appliance. Login as the root user using: server1 login: root
    password: howtoforge

    4.) Assuming that you are not German, the first thing you will want to do is change default keyboard language from German to English (or whatever your desired keyboard input language is)
    Use this:
    Code:
    # dpkg-reconfigure keyboard-configuration
    (Follow onscreen instructions.)
    Note: It may be a little tricky to enter the command properly as your keyboard input does not match the virtual machine's keyboard input... good luck :)

    5.) After selecting the desired keyboard input, restart the virtual machine so that your changes take effect
    Code:
    #systemctl reboot
    
    Now that you can properly enter commands, let's get rid of this networking error that you have seen on your last two boot sequences:
    screenshot 2
    [​IMG]

    6.) You can also verify that your networking for the guest machine is not working by running:
    Code:
    #systemctl status networking.status
    
    Which should output:
    screenshot 3
    [​IMG]

    7.) In the terminal of your guest machine use the "ifconfig -a" command to learn the name of the network interface of your guest machine:
    Code:
    # ifconfig -a
    
    screenshot 4
    [​IMG]
    NOTE: if you connect via wireless your network interface device will be "wlxxx"

    8.) Edit change default network interface "ens33" interface to the name of your network interface found in the previous step.
    Code:
    #nano /etc/network/interfaces
    
    screenshot 4
    [​IMG]

    8a.) OPTIONALLY, you can change the ip address here as well. Note: You need to be sure your new IP is within the same network range of your host machine.

    9.) After you Save & Close the file, restart the networking service and verify that the network is now working correctly
    Code:
    #systemctl restart networking.service
    
    Then check the networking service status:
    
    #systemctl status networking.service
    
    If all went well you should see:
    screenshot 5
    [​IMG]

    10a.) You should now be able to open a terminal in your host machine (Ctrl + T) and successfully ping the ip address of your guest machine using:
    Code:
    $ping 192.168.0.100    <-- OR the ip address that you created in step 8a.)
    screenshot 6
    [IMG]https://i.imgur.com/Wy9hMSx.png[/IMG] 
    NOTE:If you get this output:
    [code]
     ping: sendmsg: Operation not permitted   
    
    It means your firewall is blocking your connection attempt. Completely deactivate it or configure firewall whitelist rules accordingly.

    The next thing to do is to enable your host machine to connect with the guest machine. To achieve this you must first:

    11.) Power Off the virtual machine (do not save the state of the machine)

    12.) In the VirtualBox Manager go to "File" and select "Host Network Manager"

    13.) In the Host Manager Interface click "Create", then [DHCP] server details will appear. Check "Enable Server" in both places, and click close. It should appear as follows:

    screenshot 7
    [​IMG]

    14.) From Oracle VM VirtualBox Manager, be sure that the correct virtual machine is selected on the left hand side, then Click "Settings" at the top, and select "Network" on the left hand side of the settings interface.

    14a.) Then click "Adapter 2", and check "Enable Server"
    14b.) From the "Attached to:" drop down menu select "Host-only Adapter"
    14c.) From the "Name:" drop down menu select "vboxnet0" and finally, click "Ok"

    15.) Start your guest machine, run "ifconfig -a" again, as to confirm your network interface device name, and then run:
    Code:
     
    # ip link set dev [your network interface "enp0s17"] up
    #dhclient -v enp0s17
    
    16.) Assuming that you can successfully ping the guest machine from your host machine terminal, go ahead and create an entry in the host machine's "/etc/hosts" file for the guest machine's IP address and domain name:
    Code:
    $ sudo nano /etc/hosts
    
    **Add:
    192.168.0.100  server1.example.com server1
    
    17.) Open a web browser on your host machine and visit the guest machine's domain name as follows:
    https://server1.example.com:8080

    NOTE: Your browser will likely give you security warnings since you are using self-signed SSL certificates. Just "Accept the Risk and Continue" (firefox)

    18.) If all is well, you should see the ISPConfig login page. You can login with:
    username: admin
    password: admin

    NOTE: If you are unable log in and are met with the error message as shown below. Don't panic, you have have done everything correctly:
    [​IMG]

    Because the original admin password was created using a German keyboard input method, you will need to reset the admin password before you can proceed. Follow these instructions to reset the admin password:

    https://www.faqforge.com/linux/cont...et-the-administrator-password-in-ispconfig-3/

    The "semi" final stage of this adventure, as to get your selected ISPConfig .ova fully functional in virtualbox on your local machine, is to establish a SSH connection from the host machine to the guest machine.

    19.) Create a public/private ssh key pair by running this command on your host machine:
    Code:
    $ssh-keygen -b 4096
    
    Output:
    
    Generating public/private rsa key pair.
    Enter file in which to save the key (/home/<username>/.ssh/id_rsa):
    
    NOTE: You should change the /path/to/file/  and file name as necessary
    (i.e. /home/<username>/.ssh/id_virtualbox_rsa , in case you use multiple ssh keys)
    
    20.) Enter a passphrase when prompted ( for host to guest machines not necessary, recommend for local to remote machines)

    Expected output, should be similar to:
    Code:
    Your identification has been saved in /home/<username>/.ssh/id_rsa
    Your public key has been saved in /home/<usrname>/.ssh/id_rsa.pub
    The key fingerprint is:
    a9:49:2e:2a:5e:33:3e:a9:de:4e:77:11:58:b6:90:26 [email protected]_host
    The key's randomart image is:
    +--[ RSA 2048]----+
    |     ..o         |
    |   E o= .        |
    |    o. o         |
    |        ..       |
    |      ..S        |
    |     o o.        |
    |   =o.+.         |
    |. =++..          |
    |o=++.            |
    +-----------------+
    
    21.) On the guest machine edit "/etc/ssh/sshd_config"
    Code:
    #nano /etc/ssh/sshd_config
    **Use the following values:
    PermtRootlogin yes
    PubkeyAuthentication yes
    PasswordAuthentication yes
    
    Save & Close

    22.) Now we need to upload our public key from the host machine to guest machine. Run the following command from your host machine's terminal:
    Code:
    $ssh-copy-id [email protected]
    **Give root password when prompted (howtoforge)
    
    If all goes well your output should like this in the terminal:
    screenshot 9
    [​IMG]

    23.) Now, you should be able to ssh from your machine into your guest machine using the following command:
    Code:
    ssh [email protected]
    
    24.) Lastly, lock down your ssh connection, on your guest machine:
    Code:
    #nano /etc/ssh/sshd_config
    ** Add change these values
    PermtRootlogin without-password
    PasswordAuthentication no
    ChallengeResponseAuthentication no
    UesePAM no
    
    save & close

    25.) Reload the sshd service so that it recognizes your changes
    Code:
     
    #service sshd reload
    
    26.) From your host machine exit the ssh connection (if necessary) and try to establish a new SSH connection:
    Code:
    $ssh [email protected]
    
    If it works, you are now free wreak havoc and experiment with ISPConfig in your virtualbox, rather making your mistakes on your production server, and without numerous "noob" posts in the HowToforge help forums. (Hot Tip: virtualbox, snapshots are very, very handy)

    Optional things that I recommend if you plan to use your guest machine as your long-term test server:
    1.) Lock down the test server, meaning.. go through and change all passwords from their default & change the default ip address, as virtualbox bridged network adapters actually connect to the router.

    2.) Change the hostname from "server1" to something else. In the future, having two terminal windows open, 1 for your production server and 1 for your virtualbox test server, both having the same exact command prompt ("[email protected]") is just asking to make a major mistake in the wrong terminal window. The following command should show you all the places that "server1" should be changed to a different name on the guest machine (i.e. "test1", thereby creating "[email protected]" command prompt)
    Code:
    #grep -r "server1" /etc && grep -r "server1" /usr
    
    NOTE: Don't forget to change "server1" to "test1" on host machine as well in the "/etc/hosts" file. Also, while I was able to successfully use this method to change the hostname, it is a tedious & perilous process. BE CAREFUL. Make sure you have a virtualbox snapshot saved, before you attempt the change the hostname.

    Perhaps folks with higher linux skills than my own can make a more efficient suggestion?"

    3.) You likely need to establish a ssh ssh connection from the guest machine to your remote production server as well.
     

Share This Page