Pythian Blog: Technical Track

How to configure X11 for Vagrant Box

"Good artists copy, great artists steal" - Pablo Picasso I am currently using Vagrant boxes from Mikael Sandström (oravirt) and unfortunately, it did not have X11 configured. Typically, using CLI is better for automation; however, there may come a time where it's better to have visual. This led to a journey to configure X11 for Vagrant box. Configuration is two nodes RAC: [code] dinh@CMWPHV1 MINGW64 /d/Vagrant/vagrant-vbox-rac (master) $ vagrant status Current machine states: racnode-dc1-2 running (virtualbox) racnode-dc1-1 running (virtualbox) This environment represents multiple VMs. The VMs are all listed above with their current state. For more information about a specific VM, run `vagrant status NAME`. [/code] Install xorg-x11-apps xauth xorg-x11-fonts* for all servers. [code] [vagrant@racnode-dc1-2 ~]$ sudo su - Last login: Fri Mar 29 14:38:39 CET 2019 on pts/0 [root@racnode-dc1-2 ~]# yum install xorg-x11-apps xauth xorg-x11-fonts* ==================================================================================================================================== Package Arch Version Repository Size ==================================================================================================================================== Installing: xorg-x11-apps x86_64 7.7-7.el7 ol7_latest 307 k xorg-x11-fonts-100dpi noarch 7.5-9.el7 ol7_latest 3.1 M xorg-x11-fonts-75dpi noarch 7.5-9.el7 ol7_latest 2.8 M xorg-x11-fonts-ISO8859-1-100dpi noarch 7.5-9.el7 ol7_latest 1.1 M xorg-x11-fonts-ISO8859-1-75dpi noarch 7.5-9.el7 ol7_latest 932 k xorg-x11-fonts-ISO8859-14-100dpi noarch 7.5-9.el7 ol7_latest 1.0 M xorg-x11-fonts-ISO8859-14-75dpi noarch 7.5-9.el7 ol7_latest 905 k xorg-x11-fonts-ISO8859-15-75dpi noarch 7.5-9.el7 ol7_latest 932 k xorg-x11-fonts-ISO8859-2-100dpi noarch 7.5-9.el7 ol7_latest 1.0 M xorg-x11-fonts-ISO8859-2-75dpi noarch 7.5-9.el7 ol7_latest 901 k xorg-x11-fonts-ISO8859-9-100dpi noarch 7.5-9.el7 ol7_latest 1.1 M xorg-x11-fonts-ISO8859-9-75dpi noarch 7.5-9.el7 ol7_latest 930 k xorg-x11-fonts-Type1 noarch 7.5-9.el7 ol7_latest 521 k xorg-x11-fonts-cyrillic noarch 7.5-9.el7 ol7_latest 396 k xorg-x11-fonts-ethiopic noarch 7.5-9.el7 ol7_latest 150 k xorg-x11-fonts-misc noarch 7.5-9.el7 ol7_latest 5.8 M Installing for dependencies: libfontenc x86_64 1.1.3-3.el7 ol7_latest 30 k libpng x86_64 2:1.5.13-7.el7_2 ol7_latest 212 k libxkbfile x86_64 1.0.9-3.el7 ol7_latest 82 k ttmkfdir x86_64 3.0.9-42.el7 ol7_latest 47 k xorg-x11-font-utils x86_64 1:7.5-21.el7 ol7_latest 104 k Transaction Summary ==================================================================================================================================== Install 16 Packages (+5 Dependent packages) Total download size: 22 M Installed size: 25 M Is this ok [y/d/N]: Y Installed: xorg-x11-apps.x86_64 0:7.7-7.el7 xorg-x11-fonts-100dpi.noarch 0:7.5-9.el7 xorg-x11-fonts-75dpi.noarch 0:7.5-9.el7 xorg-x11-fonts-ISO8859-1-100dpi.noarch 0:7.5-9.el7 xorg-x11-fonts-ISO8859-1-75dpi.noarch 0:7.5-9.el7 xorg-x11-fonts-ISO8859-14-100dpi.noarch 0:7.5-9.el7 xorg-x11-fonts-ISO8859-14-75dpi.noarch 0:7.5-9.el7 xorg-x11-fonts-ISO8859-15-75dpi.noarch 0:7.5-9.el7 xorg-x11-fonts-ISO8859-2-100dpi.noarch 0:7.5-9.el7 xorg-x11-fonts-ISO8859-2-75dpi.noarch 0:7.5-9.el7 xorg-x11-fonts-ISO8859-9-100dpi.noarch 0:7.5-9.el7 xorg-x11-fonts-ISO8859-9-75dpi.noarch 0:7.5-9.el7 xorg-x11-fonts-Type1.noarch 0:7.5-9.el7 xorg-x11-fonts-cyrillic.noarch 0:7.5-9.el7 xorg-x11-fonts-ethiopic.noarch 0:7.5-9.el7 xorg-x11-fonts-misc.noarch 0:7.5-9.el7 Dependency Installed: libfontenc.x86_64 0:1.1.3-3.el7 libpng.x86_64 2:1.5.13-7.el7_2 libxkbfile.x86_64 0:1.0.9-3.el7 ttmkfdir.x86_64 0:3.0.9-42.el7 xorg-x11-font-utils.x86_64 1:7.5-21.el7 Complete! [root@racnode-dc1-2 ~]# [/code] Configure X11 for all servers. [code] [root@racnode-dc1-2 ~]# grep -i x11 /etc/ssh/sshd_config X11Forwarding yes #X11DisplayOffset 10 #X11UseLocalhost yes # X11Forwarding no [root@racnode-dc1-2 ~]# vi /etc/ssh/sshd_config [root@racnode-dc1-2 ~]# grep -i x11 /etc/ssh/sshd_config X11Forwarding yes X11DisplayOffset 10 X11UseLocalhost yes # X11Forwarding no [root@racnode-dc1-2 ~]# systemctl restart sshd.service [root@racnode-dc1-2 ~]# [oracle@racnode-dc1-2 ~]$ vi .bash_profile [oracle@racnode-dc1-2 ~]$ cat .bash_profile # .bash_profile # Get the aliases and functions if [ -f ~/.bashrc ]; then . ~/.bashrc fi # User specific environment and startup programs export PATH=$PATH:$HOME/.local/bin:$HOME/bin export DISPLAY=127.0.0.1:10.0 [oracle@racnode-dc1-2 ~]$ [/code] Update Vagrantfile to add: [code] config.ssh.forward_agent = true config.ssh.forward_x11 = true Example: -------------------------------------------------------------------------------- # Create VM's Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| config.ssh.insert_key = false config.ssh.forward_agent = true config.ssh.forward_x11 = true -------------------------------------------------------------------------------- [/code] Reload vagrant and verify X11 configuration: [code] dinh@CMWPHV1 MINGW64 /d/Vagrant/vagrant-vbox-rac (master) $ vagrant reload dinh@CMWPHV1 MINGW64 /d/Vagrant/vagrant-vbox-rac (master) $ vagrant ssh-config Host racnode-dc1-2 HostName 127.0.0.1 User vagrant Port 2222 *** UserKnownHostsFile /dev/null StrictHostKeyChecking no PasswordAuthentication no IdentityFile C:/Users/dinh/.vagrant.d/insecure_private_key IdentitiesOnly yes LogLevel FATAL ForwardAgent yes *** ForwardX11 yes *** Host racnode-dc1-1 HostName 127.0.0.1 User vagrant Port 2200 *** UserKnownHostsFile /dev/null StrictHostKeyChecking no PasswordAuthentication no IdentityFile C:/Users/dinh/.vagrant.d/insecure_private_key IdentitiesOnly yes LogLevel FATAL ForwardAgent yes *** ForwardX11 yes *** [/code] Connect as Oracle to test X11 using the correct port for the host (racnode-dc1-2): [code] dinh@CMWPHV1 MINGW64 /d/Vagrant/vagrant-vbox-rac (master) $ ssh -XY -v oracle@127.0.0.1 -p 2222 -i C:/Users/dinh/.vagrant.d/insecure_private_key OpenSSH_7.9p1, OpenSSL 1.1.1a 20 Nov 2018 debug1: Reading configuration data /etc/ssh/ssh_config debug1: Connecting to 127.0.0.1 [127.0.0.1] port 2222. debug1: Connection established. debug1: identity file C:/Users/dinh/.vagrant.d/insecure_private_key type -1 debug1: identity file C:/Users/dinh/.vagrant.d/insecure_private_key-cert type -1 debug1: Local version string SSH-2.0-OpenSSH_7.9 debug1: Remote protocol version 2.0, remote software version OpenSSH_7.4 debug1: match: OpenSSH_7.4 pat OpenSSH_7.0*,OpenSSH_7.1*,OpenSSH_7.2*,OpenSSH_7.3*,OpenSSH_7.4*,OpenSSH_7.5*,OpenSSH_7.6*,OpenSSH_7.7* compat 0x04000002 debug1: Authenticating to 127.0.0.1:2222 as 'oracle' debug1: SSH2_MSG_KEXINIT sent debug1: SSH2_MSG_KEXINIT received debug1: kex: algorithm: curve25519-sha256 debug1: kex: host key algorithm: ecdsa-sha2-nistp256 debug1: kex: server->client cipher: chacha20-poly1305@openssh.com MAC: <implicit> compression: none debug1: kex: client->server cipher: chacha20-poly1305@openssh.com MAC: <implicit> compression: none debug1: expecting SSH2_MSG_KEX_ECDH_REPLY debug1: Server host key: ecdsa-sha2-nistp256 SHA256:iwoyJMVHYg+jy4dIkKE2yEZTjUUayl89Q7qjbwqyhbQ debug1: checking without port identifier The authenticity of host '[127.0.0.1]:2222 ([127.0.0.1]:2222)' can't be established. ECDSA key fingerprint is SHA256:iwoyJMVHYg+jy4dIkKE2yEZTjUUayl89Q7qjbwqyhbQ. Are you sure you want to continue connecting (yes/no)? yes Warning: Permanently added '[127.0.0.1]:2222' (ECDSA) to the list of known hosts. debug1: rekey after 134217728 blocks debug1: SSH2_MSG_NEWKEYS sent debug1: expecting SSH2_MSG_NEWKEYS debug1: SSH2_MSG_NEWKEYS received debug1: rekey after 134217728 blocks debug1: Will attempt key: C:/Users/dinh/.vagrant.d/insecure_private_key explicit debug1: SSH2_MSG_EXT_INFO received debug1: kex_input_ext_info: server-sig-algs=<rsa-sha2-256,rsa-sha2-512> debug1: SSH2_MSG_SERVICE_ACCEPT received debug1: Authentications that can continue: publickey,gssapi-keyex,gssapi-with-mic,password debug1: Next authentication method: publickey debug1: Trying private key: C:/Users/dinh/.vagrant.d/insecure_private_key debug1: Authentications that can continue: publickey,gssapi-keyex,gssapi-with-mic,password debug1: Next authentication method: password oracle@127.0.0.1's password: debug1: Authentication succeeded (password). Authenticated to 127.0.0.1 ([127.0.0.1]:2222). debug1: channel 0: new [client-session] debug1: Requesting no-more-sessions@openssh.com debug1: Entering interactive session. debug1: pledge: exec debug1: client_input_global_request: rtype hostkeys-00@openssh.com want_reply 0 debug1: No xauth program. Warning: No xauth data; using fake authentication data for X11 forwarding. debug1: Requesting X11 forwarding with authentication spoofing. Last login: Fri Mar 29 14:54:53 2019 ---------------------------------------- Welcome to racnode-dc1-2 OracleLinux 7.3 x86_64 FQDN: racnode-dc1-2.internal.lab IP: 10.0.2.15 Processor: Intel(R) Core(TM) i7-2640M CPU @ 2.80GHz #CPU's: 2 Memory: 5709 MB Kernel: 4.1.12-61.1.18.el7uek.x86_64 ---------------------------------------- /usr/bin/xauth: file /home/oracle/.Xauthority does not exist [oracle@racnode-dc1-2 ~]$ env|grep DISPLAY DISPLAY=127.0.0.1:10.0 [oracle@racnode-dc1-2 ~]$ xclock debug1: client_input_channel_open: ctype x11 rchan 3 win 65536 max 16384 debug1: client_request_x11: request from 127.0.0.1 36236 debug1: channel 1: new [x11] debug1: confirm x11 Warning: Missing charsets in String to FontSet conversion [/code] Here is a screen capture for running gridSetup.sh: In conclusion, having X11 configured will provide options to use CLI for GUI for installing Oracle software.

No Comments Yet

Let us know what you think

Subscribe by email