How to set up a graphical interface on an Amazon EC2 Ubuntu server

I am using an instance of Amazon Ubuntu EC2, which only has a command line interface. I want to configure an interface to access this server using Remote Desktop Tools. Is there a way to apply a GUI to an EC2 instance?

+99
ubuntu amazon-web-services amazon-ec2 vnc
Sep 04 '14 at 5:00
source share
5 answers

It can be done. Below are the steps for setting up the GUI.

Create new user with login password

sudo useradd -m awsgui sudo passwd awsgui sudo usermod -aG admin awsgui sudo vim /etc/ssh/sshd_config # edit line "PasswordAuthentication" to yes sudo /etc/init.d/ssh restart 

Configuring Ubuntu based on the user interface on AWS.

In the security group, open port 5901. Then go ssh to the server instance. Run the following commands to install the user interface and vnc server:

 sudo apt-get update sudo apt-get install ubuntu-desktop sudo apt-get install vnc4server 

Then run the following commands and enter the password to enter the VNC connection:

 su - awsgui vncserver vncserver -kill :1 vim /home/awsgui/.vnc/xstartup 

Then press the Insert key, scroll through the text file using the arrows on the keyboard, and remove the pound sign (#) at the beginning of the two lines under the line that says "Uncomment the next two lines for the regular desktop." And in the second line add "sh" so that the line is read

 exec sh /etc/X11/xinit/xinitrc. 

When you're done, press Ctrl + C on your keyboard, type: wq and press Enter.

Then start the VNC server again.

 vncserver 

You can download xtightvncviewer to view the desktop (for Ubutnu) here https://help.ubuntu.com/community/VNC/Clients

In the vnc client, specify the public DNS plus ": 1" (for example, www.example.com:1). Enter the password to log in to VNC. Make sure you are using a regular connection. Do not use key files.

Additional guidance is available here: http://www.serverwatch.com/server-tutorials/setting-up-vnc-on-ubuntu-in-the-Amazon-ec2-page-3.html

VNC Client for Mac can be downloaded here: https://www.realvnc.com/en/connect/download/viewer/

Opening a port on the console

sudo iptables -A INPUT -p tcp --dport 5901 -j ACCEPT

If there is a problem with the gray window. Mostly because of the .vnc / xstartup file from another user. So start the vnc server also from the same user, and not from the user "awsgui".

Vncserver

+158
Sep 05 '14 at 18:32
source share

So, I am following the first answer, but my vnc viewer gives me a gray screen when I connect to it. And I found this Ask Ubuntu link to solve this problem.

The only difference from the previous answer is to install these additional packages:

 apt-get install gnome-panel gnome-settings-daemon metacity nautilus gnome-terminal 

And use this file ~ / .vnc / xstartup:

 #!/bin/sh export XKL_XMODMAP_DISABLE=1 unset SESSION_MANAGER unset DBUS_SESSION_BUS_ADDRESS [ -x /etc/vnc/xstartup ] && exec /etc/vnc/xstartup [ -r $HOME/.Xresources ] && xrdb $HOME/.Xresources xsetroot -solid grey vncconfig -iconic & gnome-panel & gnome-settings-daemon & metacity & nautilus & gnome-terminal & 

Everything else is the same.

Tested on EC2 Ubuntu 14.04 LTS.

+60
Mar 21 '16 at 3:07
source share

For Ubuntu 16.04

1) Install packages

 $ sudo apt update;sudo apt install --no-install-recommends ubuntu-desktop $ sudo apt install gnome-panel gnome-settings-daemon metacity nautilus gnome-terminal vnc4server 

2) Edit the file / usr / bin / vncserver and modify as shown below

Find this line

 "# exec /etc/X11/xinit/xinitrc\n\n". 

And add these lines below.

 "gnome-session &\n". "gnome-panel &\n". "gnome-settings-daemon &\n". "metacity &\n". "nautilus &\n". "gnome-terminal &\n". 

3) Create a VNC password and vnc session for the user using the "vncserver" command.

 lonely@ubuntu:~$ vncserver You will require a password to access your desktops. Password: Verify: xauth: file /home/lonely/.Xauthority does not exist New 'ubuntu:1 (lonely)' desktop is ubuntu:1 Creating default startup script /home/lonely/.vnc/xstartup Starting applications specified in /home/lonely/.vnc/xstartup Log file is /home/lonely/.vnc/ubuntu:1.log 

Now you can access the GUI using IP / domain and port 1

stackoverflow.com:1

Tested on AWS and the Digital Ocean.

For AWS, you must enable port 5901 on the firewall

Kill session

 $ vncserver -kill :1 

Cm:

https://linode.com/docs/applications/remote-desktop/install-vnc-on-ubuntu-16-04/

Refer to this guide to create regular sessions as a service.

http://www.krizna.com/ubuntu/enable-remote-desktop-ubuntu-16-04-vnc/

+12
Dec 16 '17 at 13:46 on
source share

1) Launch the Ubuntu instance on EC2.
2) Open the SSH Port in the security instance.
3) Make SSH to the instance.
4) Run:

 sudo apt-get update sudo apt-get upgrade 

5) Since you will be connecting from a remote Windows desktop, edit the sshd_config file in your Linux instance to allow password authentication.

 sudo vim /etc/ssh/sshd_config 

6) Change PasswordAuthentication to yes with no, then save and exit.
7) Restart the SSH daemon for the changes to take effect.

 sudo /etc/init.d/ssh restart 

8) Temporarily gain superuser privileges and change the password for the Ubuntu user to a complex password to increase security. Press Enter after entering the passwd ubuntu command, and you will be asked to enter the new password twice.

 sudo –i passwd ubuntu 

9) Go back to your Ubuntu user account and go to the Ubuntu home directory.

 su ubuntu cd 

10) Install the functionality of the Ubuntu desktop on your Linux instance, the last command may take up to 15 minutes.

 export DEBIAN_FRONTEND=noninteractive sudo -E apt-get update sudo -E apt-get install -y ubuntu-desktop 

11) Install xrdp

 sudo apt-get install xfce4 sudo apt-get install xfce4 xfce4-goodies 

12) Make xfce4 the default window manager for RDP connections.

 echo xfce4-session > ~/.xsession 

13) Copy .xsession to the / etc / skel folder so that xfce4 is set as the default window manager for all user accounts that are created.

 sudo cp /home/ubuntu/.xsession /etc/skel 

14) Open the xrdp.ini file to allow changing the host port to which you will connect.

 sudo vim /etc/xrdp/xrdp.ini 

(xrdp has not yet been installed. Install xrdp first with sudo apt-get install xrdp, then edit the above file)

15) Find the [xrdp1] section and change the following text (then save and exit [: wq]).

 port=-1 - to - port=ask-1 

16) Restart xrdp.

 sudo service xrdp restart 

17) On Windows, open the Remote Desktop Connection client, paste in the full name of your Amazon EC2 instance for the computer, and click Connect.

18) When prompted to log in to xrdp, make sure the sesman-Xvnc module is selected and enter the ubuntu username with the new password that you created in step 8. When you start the session, the port number is -1.

19) When the system is connected, several status messages are displayed on the connection log screen. Pay particular attention to these status messages and write down the VNC port number. If you want to return to the session later, specify this number in the port field of the xrdp login dialog box.

For more details see: https://aws.amazon.com/premiumsupport/knowledge-center/connect-to-linux-desktop-from-windows/
http://c-nergy.be/blog/?p=5305

+3
Feb 15 '16 at 11:32
source share

For LXDE / Lubuntu




1. connect to your instance (local forwarding port 5901)

ssh -L 5901: localhost: 5901 -i "xxx.pem" ubuntu@xxx.amazonaws.com

2. Install packages

sudo apt update && sudo apt upgrade
sudo apt-get install xorg lxde vnc4server lubuntu-desktop

3. Create /etc/lightdm/lightdm.conf

sudo nano / etc / lightdm / lightdm.conf

4. Copy and paste the following into lightdm.conf and save

[SeatDefaults]
allow guest = false
User -s ession = LXDE
#user -s ession = Lubuntu

5. configure vncserver (you will be asked to create a password for vncserver)

Vncserver
sudo echo "lxpanel & / usr / bin / lxsession -s LXDE &" >> ~ / .vnc / xstartup

6. Restart your instance and reconnect

reboot sudo
ssh -L 5901: localhost: 5901 -i "xxx.pem" ubuntu@xxx.amazonaws.com

7. Launch vncserver

vncserver -geometry 1280x800

8. In the remote desktop client (for example, Remmina), set the server to localhost: 5901 and the protocol for VNC.

+1
May 18 '18 at 14:22
source share



All Articles