Documentation
    Amazon Web Services
    Microsoft Azure
    RapidAPI
    APILayer
Last Update: 2024-03-01

Selenium with Tor Browser on Ubuntu with GUI


Table of Content


Launch Selenium with Tor Browser on Ubuntu with GUI
Connect to GUI (RDP and VNC)
Run our sample code and develop your own scripts
Connect to your VM via SSH
Deploy files on your VM remotely
Manage VNC Server
Troubleshooting

Launch Selenium with Tor Browser on Ubuntu with GUI

 Navigate to our listing page on the AWS Marketplace and click 'Continue to Subscribe'.

On the subsequent page, review and accept our terms by selecting 'Accept Terms'.

Once the subscription process is complete, select 'Continue to Configuration'.

Choose the region where you wish to deploy the virtual machine, then click 'Continue to Launch'.

On the final page, select the instance type you wish to use (the recommended instance type is pre-selected) and review the other launch options. Then, click 'Launch'.

After launching, you can view your instance in the EC2 Management Console.

Connect to GUI (RDP and VNC)


Access the EC2 Management Console (ensure to be in the correct AWS region) to retrieve the public IP address of your virtual machine. For the VNC connection, use the instance ID as the password (e.g. i-0a85cdce733efbb08). The username to use is 'ubuntu'.

Open 'Remote Desktop Connection' and connect by using the public IP address of your virtual machine.

When prompted, enter 'ubuntu' as the username and the instance ID of your virtual machine as the password (please refer to the previous steps).

Run our sample code and develop your own scripts


Connect to the instance using RDP or VNC, and log in as the user 'guiuser'.

Open the Tor Browser

First, we need to open the Tor browser to establish a connection to the Tor network. Navigate to the directory Desktop -> SeleniumWithTor -> tor-browser_en-US, and double-click on the Tor Browser icon. Wait for the browser to start. The window must remain open in the background while you proceed with the next steps.

Open a terminal window and navigate to the /home/ubuntu/Desktop/Selenium directory by entering:

cd /home/ubuntu/Desktop/Selenium

Start the script with the command:

python3 sample-tor.py

If everything goes as expected, you will see the script's output on the screen.

To edit the script, right-click on it and open it with Sublime Text.

Connect to your VM via SSH


Please see the official documentation for detailed instructions on how to connect to a virtual machine with SSH.

Go to the EC2 Management Console and select the virtual machine to obtain its Public IPv4 address.

Open a Command Prompt / Terminal window and navigate to the directory where your created .pem key file is located. You can connect to your VM with the user 'ubuntu' by executing the following command:

ssh -i <name-of-key-file.pem> ubuntu@<public-ip>

Deploy files on your VM remotely

Download and install WinSCP or any other SCP client of your choice.

Choose 'SFTP' as the file protocol and enter the public IP address of your instance, using 'ubuntu' as the username.

Click on 'Advanced'.

In the left-side menu, select 'Authentication'. Under Authentication parameters, select the key file you created when you launched the virtual machine. When prompted, convert the .pem key file to PuTTY format.

Close the Authentication window by clicking on 'OK', and connect to the virtual machine by clicking on 'Login'.

Manage VNC server

When you reboot your instance, a cron job script automatically starts the RDP and VNC services. To update this script, connect to the terminal via SSH and log in as 'ubuntu'.

The startup script is located at /home/ubuntu/.vnc/startVNC.sh. To edit the script, type:

nano /home/ubuntu/.vnc/manage-vnc.sh

If you wish to change the display size of the desktop, for example, you can add the desired X and Y dimensions using the -geometry parameter to the vncserver :1 start command.

After making your changes, save the file by pressing Control+O, then exit nano by pressing Control+X. Finally, reboot the VM using:

sudo reboot

Troubleshooting

Resolving RDP/VNC Connection Issues

Encountering difficulties with RDP/VNC connections to your virtual machine can be frustrating. To address these issues effectively, ensure you're using the correct credentials and IP address as outlined in the "Connect to GUI (RDP and VNC)" section.

It's important to note that the RDP/VNC server on the virtual machine is configured to restart with every system reboot. Therefore, restarting the virtual machine might resolve any connectivity problems you're experiencing. If, however, the connection issues persist and cannot be resolved, you may need to consider deploying a new virtual machine.

Additionally, be aware that certain local networks—particularly those within corporate environments—may impose restrictions on network traffic, including blocking ports commonly used for remote connections, such as SSH (port 22), RDP (port 3389), and VNC (port 5901). Prior to attempting an RDP/VNC connection to your virtual machine, verify that your internal network policies do not obstruct these ports, ensuring a seamless connection process.

How to Utilize the Clipboard for Copy & Paste Operations

Most RDP and VNC clients are designed to integrate with your system's clipboard, enabling straightforward copy (Ctrl+C) and paste (Ctrl+V) functionality. This feature allows you to copy text or files on one end and paste them on the other without any complex procedures.

Using "Remote Paste" Feature: Some clients offer an enhanced feature known as "remote paste." This option can usually be found within the client's settings or preferences menu. When enabled, it optimizes the process for copying content from your local system to the virtual machine, ensuring smoother and potentially faster transfers.

Steps for Effective Copy & Paste:

For Text:

  1. Select the text you wish to copy on your local machine.
  2. Press Ctrl+C to copy the text to the clipboard.
  3. Switch to your RDP or VNC client window where the virtual machine is running.
  4. Press Ctrl+V to paste the text within the virtual machine environment.

For Files:

  1. Highlight the file(s) on your local system that you want to transfer.
  2. Use Ctrl+C to copy the selected file(s).
  3. Move to the virtual machine via your RDP or VNC client.
  4. Press Ctrl+V to paste the file(s) into the desired location on the virtual machine.

Troubleshooting Tips:

Clipboard Not Working? If you encounter issues with the clipboard functionality, first ensure that clipboard sharing is enabled in your RDP/VNC client's settings. This setting is crucial for copy-paste operations to work across your local system and the virtual machine.

File Transfer Fails? Ensure that the client and virtual machine both support file transfer via clipboard. Some setups may require additional configuration or support only text copy-paste by default.

Performance Issues: For large files or slow connections, consider using dedicated file transfer protocols or services instead of clipboard operations for a more reliable and efficient transfer process.