- Install the VNC Remote Access Server on Oracle Linux 8
- Introduction
- Background
- Objectives
- Prerequisite
- Install a graphical desktop environment
- Install the VNC packages
- Set the VNC password
- Configure the VNC service
- Set up the VNC service
- Configure X509 encryption (optional)
- Configure firewall rules (optional)
- Open a VNC client and test your deployment
- Video demonstration
- For More Information
- More Learning Resources
- Connecting to an Instance
- Required IAM Policy
- Prerequisites
- Connecting to a Linux Instance
- Connecting to a Windows Instance
- Prerequisites
- Making the Connection
- Connecting to an Instance on a Private Subnet Using a Bastion
- Troubleshooting the SSH Connection
Install the VNC Remote Access Server on Oracle Linux 8
Introduction
This tutorial shows you how to install and set up the VNC remote access server software on an Oracle Linux 8 system to enable you to remotely operate a graphical desktop environment.
Background
Virtual Network Computing (VNC) is a graphical desktop sharing system that controls remote machines by sending keyboard and mouse events over the network. VNC is particularly useful for remotely controlling Oracle Linux servers that have a graphical desktop environment installed.
You can connect to a VNC server by using any compatible software client. VNC is suitable for thin client computing where multiple dumb terminals can share the same hardware resources that are hosted on an Oracle Linux server.
This tutorial uses TigerVNC to illustrate how to remotely connect to systems. However, you can use a different VNC software of your choice. Some alternative software is listed at the end of the tutorial.
TigerVNC Server was rebased from 1.9.0 to 1.10.1 in Oracle Linux 8 Update 3. This newer version is configured differently to previous versions and no longer requires the creation of systemd unit files. The instructions provided here assume that you are using the latest version.
Objectives
In this tutorial you:
- Install a graphical desktop environment along with the VNC service
- Set the VNC Password for a user on the system
- Configure the VNC service for a specific user
- Start and enablve the VNC service across subsequent boots
- Optionally enable x509 encryption for direct VNC access
- Optionally create firewall rules to allow direct VNC access
- Access the VNC server from a remote client, either directly or using an SSH tunnel
Prerequisite
- Any system with Oracle Linux 8 installed
- Client software such as TigerVNC
Install a graphical desktop environment
Install a GNOME desktop environment and all of its dependencies.
Set graphical mode as the default login type for user accounts, then reboot the server.
Uncomment the following line in the /etc/gdm/custom.conf file to ensure that VNC uses X.org instead of Wayland:
Install the VNC packages
Install the VNC server package and all of its dependencies.
Set the VNC password
Create a VNC password for the user account that you intend to use for remote sessions.
The command prompts you for a password and then prompts you again to validate the password. Optionally you are able to set a ‘view-only’ password that allows you to share the screen but not allow control over the mouse or keyboard.
This action generates configuration information specific to the user account in $HOME/.vnc/ . If this directory already exists from a previous installation, you can either remove the directory prior to running the vncpasswd command; or you can restore the SELinux context on the directory to ensure that you do not have any issues with SELinux for this service. For example:
Configure the VNC service
Append the user account and the X Server display for the VNC service to /etc/tigervnc/vncserver.users file:
Also append the default desktop and screen resolution to the /etc/tigervnc/vncserver-config-defaults file:
By default, the VNC server terminates when the last user signs out. You can manually force the VNC server to persist by creating the /etc/systemd/system/vncserver@.service.d/10-restart.conf file as the root user, and then adding the following content:
Set up the VNC service
Reload the systemd service, then enable and start the VNC server by using X Server display 1:
Configure X509 encryption (optional)
By default, VNC is not an encrypted protocol and you should use an SSH tunnel to access it across an unprotected network. You can configure X509 TLS to encrypt your VNC session, however this requires that your client software supports X509Vnc encryption and has access to the CA certificate used to sign your certificates.
If you do not have a CA signed certificate, you can use self-signed certificates, but your client system must have a copy of the public certificate to be able to connect. To create a self-signed certificate, run:
Edit the user’s custom VNC configuration options in `
/.vnc/config`. If the file does not exist yet, you may need to create it yourself. Update the configuration to enable x509Vnc encryption and to provide the full path to the X509 key file and that x509 certificate file. For example, assuming that the username is opc, the following configuration should work correctly:
Note that you must provide the full path to the key and certificate files. You cannot depend on shell expansion or use variables for this purpose.
When you have finished editing the configuration, you can restart the service:
Configure firewall rules (optional)
If you are using X509 encryption and you are running a custom firewall profile or an Oracle Cloud Infrastructure instance, you can open the firewall port for the VNC service (5901) on your firewall or in your security lists for your network.
If you are using X509 encryption and the firewalld service is running on the host, you can add access for the VNC service. Then, reload the default firewall service.
Note: VNC is not an encrypted protocol and you should not open the firewall to this port and connect directly to a VNC server over an unprotected network. Although we list this step as optional, it is not generally advised and you should consider using SSH tunneling or some other mechanism to protect the connection.
Open a VNC client and test your deployment
If your client is running Oracle Linux 8, you can install the TigerVNC software client:
On the client machine, use the VNC software to connect to the remote Oracle Linux server domain or IP address. Make sure to specify the correct port. The default VNC port is 5900, but that number is incremented according to the configured display number. Thus, display 1 corresponds to 5901, display 2 to 5902, and so on.
Note that if you enabled X509 encryption, you may need to provide the CA certificate used to sign your keys, or if you used a self-signed certificate you can use the public certificate as the CA certificate. Some clients may be willing to allow you to simply accept a self-signed certificate automatically.
If you encounter connectivity problems, troubleshoot these issues by connecting to the remote server over an SSH connection that has been configured for an SSH tunnel. Then, use the tigervnc client to connect to the local host:
Video demonstration
The video demonstration and tutorial provided at https://www.youtube.com/watch?v=Z5vhER7K34E may also be useful if you need more information on configuring a VNC server.
For More Information
Other related resources include:
- Tiger VNC Server configuration documentation in /usr/share/doc/tigervnc/HOWTO.md/
- GNOME desktop sharing with Vino at https://wiki.gnome.org/Projects/Vino
- KDE desktop sharing with Krfb at https://kde.org/applications/internet/org.kde.krfb
- Using VNC client software such as:
- Vinagre; or
- KRDC
- Oracle Linux Documentation
The basic steps included in this tutorial are available in the shell script at ol8-vnc-setup.sh
More Learning Resources
Explore other labs on docs.oracle.com/learn or access more free learning content on the Oracle Learning YouTube channel. Additionally, visit education.oracle.com/learning-explorer to become an Oracle Learning Explorer.
For product documentation, visit Oracle Help Center.
Install the VNC Remote Access Server on Oracle Linux 8
Copyright © 2021, Oracle and/or its affiliates.
Источник
Connecting to an Instance
You can connect to a running instance by using a Secure Shell (SSH)В or Remote Desktop connection. Most UNIX-style systems include an SSH client by default. Windows 10 and Windows Server 2019 systems should include the OpenSSH client, which you need if you created your instance using the SSH keys generated by Oracle Cloud Infrastructure . For other Windows versions, you can download a free SSH client called PuTTY from http://www.putty.org.
Note
If you created an instance without an SSH key, you can use the serial console to boot into maintenance mode and add or reset the SSH key for the opc user or reset the password for the opc user. Alternately, you can stop the instance, attach the boot volume to a new instance, and configure SSH on the new instance.
Required IAM Policy
To connect to a running instance with SSH, you don’t need an IAM policyВ to grant you access. However, to SSH you need the public IP address of the instance (see Prerequisites below). If there’s a policy that lets you launch an instance, that policy probably also lets you get the instance’s IP address. The simplest policy that does both is listed in Let users launch compute instances.
For administrators: Here’s a more restrictive policy that lets the specified group get the IP address of existing instances and use power actions on the instances (for example, stop or start the instance), but not launch or terminate instances. The policy assumes the instances and the cloud network are together in a single compartment (XYZ):
Prerequisites
You’ll need the following information to connect to the instance:
- The public IP address of the instance. You can get the address from the Instance Details page in the Console . Open the navigation menu and click Compute . Under Compute , click Instances. Then, select your instance. Alternatively, you can use the Core Services API ListVnicAttachments and GetVnic operations.
- The default username for the instance. If you used a platform image for Linux, CentOS, or Windows to launch the instance, the username is opc . If you used an Ubuntu platform image to launch the instance, the username is ubuntu .
- For Linux instances: The full path to the private key portion of the SSH keyВ pair that you used when you launched the instance. For more information about key pairs, see Managing Key Pairs on Linux Instances.
- For Windows instances: If you’re connecting to the instance for the first time, you will need the initial password for the instance. You can get the password from the Instance Details page in the Console .
Connecting to a Linux Instance
You connect to a Linux instance using SSH.
Use the following command to set the file permissions so that only you can read the file:
is the full path and name of the file that contains the private key associated with the instance you want to access.
Use the following SSHВ command to access the instance.
Note
Copy the following example to ensure the correct characters are used. If the wrong character is used in ssh -i , a Could not resolve hostname . No such host is known. error might occur.
is the full path and name of the file that contains the private key associated with the instance you want to access.
is the default username for the instance. For Oracle Linux and CentOS images, the default username is opc . For Ubuntu images, the default username is ubuntu .
is your instance IPВ address that you retrieved from the Console .
If the instance uses a key pair that was generated by Oracle Cloud Infrastructure , use the following procedure.
If this is the first time you are using this key pair, you must set the file permissions so that only you can read the file. Do the following:
- In Windows Explorer, navigate to the private key file, right-click the file, and then click Properties.
- On the Security tab, click Advanced.
- On the Permissions tab, for Permission entries, under Principal, ensure that your user account is listed.
- Click Disable Inheritance, and then select Convert inherited permissions into explicit permissions on this object.
- For Permission entries, select each permission entry that is not your user account and click Remove.
- Ensure that the access permission for your user account is Full control.
- Save your changes.
To connect to the instance, open Windows PowerShell and run the following command:
Note
Copy the following example to ensure the correct characters are used. If the wrong character is used in ssh -i , a Could not resolve hostname . No such host is known. error might occur.
is the full path and name of the file that contains the private key associated with the instance you want to access.
is the default username for the instance. For Oracle Linux and CentOS images, the default username is opc . For Ubuntu images, the default username is ubuntu .
is your instance IPВ address that you retrieved from the Console .
SSH private key files generated by Oracle Cloud Infrastructure are not compatible with PuTTY. If you are using a private key file generated during the instance creation process you need to convert the file to a .ppk file before you can use it with PuTTY to connect to the instance.
Note
If you changed the file permissions on your key to connect from a Windows system using OpenSSH, the key will not work with a PuTTY connection. Use OpenSSH to connect instead.
Convert a generated .key private key file:
Click Load, and select the private key generated when you created the instance. The extension for the key file is .key .
Click Save private key.
Specify a name for the key. The extension for new private key is .ppk .
Connect to the Linux instance using a .ppk private key file:
If the instance uses a key pair that you created using PuTTY Key Generator, use the following procedure.
In the Category pane, select Session and enter the following:
Host Name (or IP address):
is the default username for the instance. For Oracle Linux and CentOS images, the default username is opc . For Ubuntu images, the default username is ubuntu .
is your instance public IPВ address that you retrieved from the Console
Click Browse, and then select your .ppk private key file.
Click Open to start the session.
If this is your first time connecting to the instance, you might see a message that the server’s host key is not cached in the registry. Click Yes to continue the connection.
Tip
If the connection fails, you may need to update your PuTTY proxy configuration.
Connecting to a Windows Instance
You can connect to a Windows instance using a Remote Desktop connection. Most Windows systems include a Remote Desktop client by default.
Prerequisites
To use Remote Desktop Protocol (RDP) to access the Windows instance, you need to add a stateful ingress security rule for TCP traffic on destination port 3389 from source 0.0.0.0/0 and any source port. You can implement this security rule in either a network security group that the Windows instance belongs to or a security list that is used by the instance’s subnet.
- Open the navigation menu and click Compute . Under Compute , click Instances.
- Click the instance that you’re interested in.
- Under Instance details, for Virtual cloud network, click the name of the cloud network. The Virtual Cloud Network Details page opens.
To add the rule to a network security group that the instance belongs to:
- Under Resources, click Network Security Groups.
- Click the network security group that you’re interested in.
- Click Add Ingress Rules.
Enter the following values for the rule:
- Stateless: Leave the check box cleared.
- Direction: Leave Ingress selected.
- Source Type: CIDR
- Source CIDR: 0.0.0.0/0
- IPВ Protocol: RDP (TCP/3389)
- Source Port Range: All
- Destination Port Range: 3389
- Description: An optional description of the rule.
- Open the navigation menu and click Compute . Under Compute , click Instances.
- Click the instance that you’re interested in.
- Under Primary VNIC, for Subnet, click the name of the subnet. The Subnet Details page opens.
To add the rule to a security list that is used by the instance’s subnet:
- Under Resources, click Security Lists.
- Click the security list that you’re interested in.
- Click Add Ingress Rules.
Enter the following values for the rule:
- Stateless: Leave the check box cleared.
- Source Type: CIDR
- Source CIDR: 0.0.0.0/0
- IPВ Protocol: RDP (TCP/3389)
- Source Port Range: All
- Destination Port Range: 3389
- Description: An optional description of the rule.
Making the Connection
- Open the Remote Desktop client.
- In the Computer field, enter the public IP address of the instance. You can retrieve the public IP address from the Console .
- The User name is opc . Depending on the Remote Desktop client you are using, you might have to connect to the instance before you can enter this credential.
- Click Connect to start the session.
- Accept the certificate if you are prompted to do so.
If you are connecting to the instance for the first time, enter the initial password that was provided to you by Oracle Cloud Infrastructure when you launched the instance. You will be prompted to change the password as soon as you log in. Your new password must be at least 12 characters long and must comply with Microsoft’s password policy.
Otherwise, enter the password that you created. If you are using a custom image, you might need to know the password for the instance that the image was created from. For details about Windows custom images, see Creating Windows Custom Images.
Connecting to an Instance on a Private Subnet Using a Bastion
A subnet attached to an instance is either public or private. Instances on a private subnet can’t have public IP addresses. Oracle Cloud Infrastructure Bastion provides restricted and time-limited access to instances that don’t have public IP addresses.
Bastions let authorized users connect from specific IP addresses to instances using SSH sessions. When connected to a session, users can interact with the instance by using any software or protocol supported by SSH.
The Bastion service recognizes two types of sessions.
- Managed SSH sessions provide administrative access to the instance’s operating system. To connect to an instance using this session type the Bastion plugin must be enabled on the instance, and plugins must be running. For more information about how to enable and run plugins, see Managing Plugins with Oracle Cloud Agent.
- Port forwarding sessions (also known as SSH tunneling) create a secure connection between a specific port on the client machine and a specific port on the instance. Using this SSH connection you can relay other protocols like the Remote Desktop Protocol (RDP).
Troubleshooting the SSH Connection
If you’re unable to connect to your instance using SSH, follow these troubleshooting steps to identify common problems.
- Verify your connection: In your terminal window, run nc
If the SSH banner displays: You successfully connected to your instance using SSH. The underlying problem might be related to permissions. As a next step, verify your credentials. If the credentials you’re using to SSH to the instance are incorrect, the connection fails.
For Linux instances, you need the full path to the private key portion of the SSH keyВ pair that you used when you launched the instance. For more information about key pairs, see Managing Key Pairs on Linux Instances. For Windows instances, if you’re connecting to the instance for the first time, you need the initial password for the instance. You can get the password from the Instance Details page in the Console .
Capture serial console history: You can capture your instance’s serial console data history in the Console or by using the console-history resource in the CLI. This information can help determine the cause of connectivity problems. For more information about using the CLI, see console-history and Command Line Interface (CLI).
When using the CLI to capture the instance’s serial console data history, you need to include the following option to ensure that full history is captured. Without this option, the data might be truncated: —length 10000000 .
Источник