How to set up VPS (Windows and Linux): connecting to a virtual server, updating, firewall, managing users and programs
Traditional hosting is increasingly being replaced by VPS (virtual) hosting, because recently competitive prices have been offered for this service, and the latter has more advantages. VPS is isolated within the OS. Although it shares a physical server with its neighbors, it has its own resources. You can manage the virtual server yourself by installing the necessary software yourself. All files are isolated from other clients and private. But VPS differs from traditional hosting in that it requires configuration at the server administrator level. In this article we will look at, how to set up VPS.
What you need to know to set up a VPS
First, check the IP address issued by your provider for blocking. The Roskomnadzor website and almost any option offered by a search engine can help with this:
ip blacklist check
Servers operate mainly using Linux-like operating systems, with Windows also available. The former allow you to configure the infrastructure more finely, but the latter may be required to solve specific problems (.NET applications, etc.).
What's included in VPS setup:
- connection, server management using commands;
- installation and updating of software;
- user account management;
- firewall settings.
You can interact with the server using the graphical interface and command line. The latter is more effective.
Connecting to VPS
First you need to establish a connection with the server. It is safe and fast to use an SSH connection (Secure Shell). You should receive a letter from your provider (or information in your personal account) containing the IPv4 and IPv6 addresses, SSH username and password. As a rule, this is data at the root (superuser) level, which has maximum rights on this server.
VPS on Linux
For a Unix based system, the command line is sufficient. You need to enter in it:
ssh root@хх.хх.ххх.ххх
- where instead of xx.xx.xxx.xxx you need to supply the IPv4 address data;
- after that you need to enter a password.
Most users use the pre-installed OpenSSH client. You can download PuTTY, which will help with debugging, for connecting to various ports, with raw sockets.
VPS on Windows
Windows will require the use of some client, for example, the same PuTTY or Bitvise, or another.
After starting the program, you need to specify the settings:
- Host name (or IP address): data issued by the provider.
- Saved Sessions: Custom connection name.
- Port: port number 22. It is used in addition to SSH connections for the SFTP protocol and secure login. Maybe different.
- Connection type:connection type is SSH.
After saving the settings (Save) must be pressed Load, and then Open. Modal window PuTTY Security Alert will ask you to confirm that you trust the service. In the window that opens you need to enter your login root, press Enter, and then the password and press again Enter. After this you will have access to the VDS shell (bash by default). For key authentication, you will need to generate special RSA keys.
The most common SSH commands
Basic terminal management skills will require knowledge of at least the following commands:
: clear the terminal window;clear
: show the last 50 teams;history
: delete a file;rm
: text editors;vi/nano
: search for files and folders;find
: search for a phrase in a file;grep
: show directory contents;ls
: change directory;cd
: create a new folder or directory;mkdir
: create file;touch
: delete a file;rm
: show file contents;cat
: show current directory or full path;pwd
: copy file or folder;cp
: move file or folder;mv
: Find out information about the program.whatis
To exit the terminal, you need to dial
exit
You will also need to change your password root and other primary settings, which will include choosing a time zone, reassigning rights, kernel updates and others.
An alternative to SSH is VNC
In addition to SSH access, a good provider will provide VNC. The graphical shell allows you to work with the mouse, end the session and disconnect connections. First of all, this is needed for emergency situations such as server freezes, loading errors, etc.
RDP connection
If the operating system is Windows, then it is more convenient to connect via RDP (but you can also do this on Linux) via a remote desktop.
What you need to do for this on Windows:
- Open Start -> Run -> enter mstsc -> click Enter.
- In the Компьютер introduce IP Address server and connect.
- A prompt to connect to the VPS should appear.
If the operating system is Linux, then to connect via RDP you need to use a special RDP client: Remmina, Vinagre, Xfreerdp, Rdesktop.
What to do on Linux:
- Open a command shell using
xterm
- To enter
to understand whether it is installed or not.rdesktop
- If installed, you need to enter
and server IP address.rdesktop
Request example:
$ RDesktop 72.52.246.40
Control via panel
Virtual hosting requires administration skills. But for those who want to take advantage of the benefits of VPS and not spend a lot of time on preparatory work, there is an option to find a provider that offers quick setup services. For example, at the address you can have a fast, trouble-free environment within half an hour.
HostZealot offers various hosting control panels. They greatly simplify the installation, configuration and administration of a virtual server. HostZealot offers various hosting management panels. They greatly simplify the installation, configuration and administration of a virtual server.
The functionality of the panels is wide: setting up a web server, DNS, managing the database, mail services, file manager, setting up backups, configuring the OS. Some contain additional features: plugins and scripts for managing CMS sites, reseller accounts, billing system, integration with additional services. Free solutions: VestaCP, VirtulaMin. Paid solutions: ISPmanager, DirectAdmin, WHM/cPanel.
Virtual server update
When you log into the server, information is shown whether there are any system updates or packages. This step should not be skipped, because outdated configurations may be less secure, which is why new patches are released. Command (in Debian, Ubuntu and the like)
apt update
will check the packages and
apt dist-upgrade
will update installed software packages After installation, you must click reboot, close the connection and log in again. No updates should be offered at this stage.
Installing a firewall
A virtual server needs security; a firewall (packet filter) is used for this.
VPS on Linux
For Linux OS there is an Iptables firewall, with which you can allow or block traffic. If it is missing, you can install it using
apt-get install iptables
If another firewall is used, it must be disabled. A special shell for Iptables was developed - UTF (Uncomplicated Firewall). You can install it using the command:
apt install ufw
The firewall status can be viewed using:
ufw status verbose
By default, the firewall allows all outgoing connections and denies all incoming connections. UTF allows you not to remember all the ports; it is enough to allow connection via SSH:
ufw allow ssh
if you need to specify a specific port:
ufw allow 3333
Enablement occurs with the command:
ufw enable
after which you need to answer the question: Command may disrupt existing ssh connections. Proceed with operation (y|n)?by selecting a letter y or n. You can check the current active rules with the command:
ufw status
VPS on Windows
The Windows server uses a good built-in firewall, so there is no need to install a third-party one. You need to customize what you have. To do this, you can use the CMD command line (run as administrator). The team will help you do this netsh:
netsh advfirewall set allprofiles state off
- enable firewall
netsh advfirewall set allprofiles state on
Network profiles may need to be enabled, for example:
netsh advfirewall set domainprofile state off
or turn it off, for example:
netsh advfirewall set domainprofile state on
Denying all incoming connections and allowing all outgoing connections organizes the request:
netsh advfirewall set allprofiles firewallpolicy blockinbound,allowoutbound
The command will help you close a port for receiving protocols (using TCP for port 80 as an example):
netsh advfirewall firewall add rule name="HTTP" protocol=TCP localport=80 action=block dir=IN
In a similar case, you can resolve it by sending
netsh advfirewall firewall add rule name="Open Port 80" dir=in action=allow protocol=TCP localport=80
You can also configure the firewall in the web server control panel, if it allows you to do so. Access to unused ports should be closed, and ports that are used for clients should be limited to a list of IP addresses, for example:
- 80 and 443 - for the web server;
- 1433-1434 - for SQL;
- 53 - for DNS;
- 990 - FTPS;
- 3389 - for RDP.
As a result, only certain ports from certain IPs will be able to be accessed.
user management
VPS management occurs with root rights, but it is usually recommended to use another account with superuser rights. Thoughtlessly using root can cause irreparable damage if you don't really know what you're doing. One wrong command can create serious problems. Please note that when working under a different user, you will need to add a prefix to all commands sudo.
VPS on Linux
In Linux, to create a new user, use the commands
useradd (-n) newuser
и
adduser newuser
. The first is a lower-level utility, and the second is simpler and acts as an add-on over
useradd
groupadd
usermod
If adduser is in the distribution, you need to use it. Set password:
passwd username
and add the user to the group:
usermod -aG sudo username
VPS on Windows
Adding users to a Windows server depends on its version, but in general this is done through the Control Panel. IN Server Manager Need to find Computer Management and Local users find a list of users and a button to add a new one.
Installing the necessary programs
Depending on the needs of the VPS server, software is installed on it. This could be a desire to host a website, a trading bot, a chat bot or telegram bot, a game server, organize video surveillance, control IoT devices, host a CRM system, etc. Examples of what can be installed: PHP, MySQL, Apache, PHPMyAdmin, Redmine, OpenVPN, TeamSpeak, Django, Tomcat, 1C, IIS, ASP.NET, MSSQL and other software.
VPS hosting rental on this website https://www.reg.ru/vps/cloud/ will allow you to get all the necessary services: servers with Linux or Windows, the necessary parameters of CPU, RAM, disk space. Servers are located in Europe, North America and Asia.
Those who do not want to set up a virtual server on their own can take advantage of the hosting company’s help with initial setup and administration at any stage of VPS ownership.
This will allow you to get all the advantages of a virtual server and minimize its disadvantage in the form of the requirement for server administration skills.