Quantcast
Channel: System Administration News » systems administration
Viewing all articles
Browse latest Browse all 5

SSH and initial configuration of a dedicated server

0
0

How to connect via SSH command line to the dedicated server to administer whole server? Initial Server Setup, how to log in as root, how to edit files,etc:-

These accesses are created either by yourself during installation or provided by your hosting dedicated server after installing the system.

To administer the dedicated server with these identifiers, it is necessary to connect from the command line via SSH (Secure Shell).

Linux

Open a terminal and use the command ssh test.yourdomain.com -l dew

Specifying port 22 (default): ssh test.yourdomain.com -l dew -p 22
Windows: Putty

The best Windows SSH client relationship at present is Putty . You simply specify the address of your server (and possibly the port if it differs from the default port 22 for SSH) to connect it to the server.

Putty SSH

ssh-putty

Feel free to customize the display in Window> Colours (background color, font) to make you feel at home. In Window> you can choose the character set (ISO / UTF-8) if accented characters are not displayed correctly.

Root (super administrator)

To configure your server, you’ll need to run commands super-administrator mode. This is a user who has the maximum privileges on the machine. Normally you have to choose a password during the installation of your server.

Ubuntu

Use sudo before each command. For example: sudo apt-get install nano
Debian

Simply use the command su and enter the root password, or install sudo like Ubuntu with apt-get install sudo and set the rights with visudo .

Manual

For more information about a command or a program, use the Linux manual by typing man followed by the command name.

  • ls: List the contents of the current directory
    cd: Change directory (eg cd / etc /)
    mv: Move (or rename) a file
    cp: copy a file
    rm: Removes a file (recursively:-rf)
    rmdir: Removes a directory
    mkdir: Creates a directory

The configuration files are usually all stored in / etc /, executable programs in / bin / or / usr / bin / document files (web, mail, mysql) in / var and / home directories in / home / except for root that has / root /.
Change the root password

Feel free to change the password especially if it was given to you by default. Log in as root first (see above) and enter the command:

passwd root
Editing files

To edit the files on the command line (SSH) many text editors available. If you are new to Linux Ubuntu or Debian, we recommend nano, which is relatively easy to access. You can install it with apt-get install nano . Otherwise, prefer vi (or vim) which is very powerful. This is the editor that we use in the tutorials in this section.

Vi few basic commands:

  • i: Insert text
    a: Add text
    Esc: Exit the previously selected (or i) fashion
    x: Delete a character
    dd: Clear / off line
    Y: Copy a line
    p: Paste online
    o: Insert a new line
    u: Undo the last action
    : W: Save File
    Q: Quit
    : Q! : Exit without saving
    / Mot_à_chercher: Search for a word
    n Search the following word
    : G/mot1/s / / word2 / g: Search All file to replace the string1 by string2

SSH configuration

To secure SSH access to the server, publish / etc / ssh / sshd_config file. We will change the connection port default to avoid some bruteforce attacks on port 22, which is well known for hosting the service. Do not forget to specify the new port (in Putty or ssh command line Linux) at the next login.

vi /etc/ssh/sshd_config

Port 1337 # Changer le port par défaut PermitRootLogin no # Ne pas permettre de login en root Protocol 2 # Protocole v2 AllowUsers

Restart the SSH service after these changes:

/etc/init.d/ssh restart
Basic configuration of the network

Verify that the hostname of your machine is correct or personalize it by editing / etc / hostname. It must also reflect the reverse configured with your host or datacenter.

vi /etc/hostname

In our example case, we will specify test.yourdomain.com

Check the / etc / hosts file

vi /etc/hosts

It should look something like this, with your own IP address and domain name:

127.0.0.1 localhost test 88.150.120.130 test.yourdomain.com test

We will also optimize some server security along the way. Network do not change these unless you know what you’re doing.

echo "1" > /proc/sys/net/ipv4/icmp_echo_ignore_broadcasts echo "0" > /proc/sys/net/ipv4/conf/all/accept_source_route echo "1024" > /proc/sys/net/ipv4/tcp_max_syn_backlog echo "1" > /proc/sys/net/ipv4/icmp_ignore_bogus_error_responses

Edit the file / etc / resolv.conf to check or add the DNS servers to use:

vi /etc/resolv.conf

nameserver ip_serveur_dns_1 nameserver ip_serveur_dns_2

After these changes we can restart the network service:

/etc/init.d/networking restart

Or more radically restart the server:

reboot

Wait a few minutes and then reconnect. Check the changes with the following commands:

hostname-f
should return the FQDN or test.yourdomain.com in our example
hostname-s
must return the short name, or test
hostname-d
must return the domain or yourdomain.com
hostname-i
returns the IP address

Administration

Updates with APT

APT is a manager of high performance packages. It will allow you to add or remove programs in the Linux distribution. To begin, put the list of updated packages from servers Reference: apt-get update

Then proceed to update the system. The packages will be replaced by their updates: apt-get upgrade

Here are some very useful APT commands:

  • apt-get dist-upgrade
    Updates the entire distribution
    apt-get install package
    Install the package mentioned
    apt-get install package-s
    Installation Simulation
    apt-get remove package
    Uninstall / remove the package
    apt-get remove package – purge
    Complete uninstall (including configuration files)
    apt-cache show package
    Package Information
    apt-cache search package
    Search packages available
    apt-cache depends package
    Dependencies
    apt-cache madison package
    Versions available
    apt-cache policy package
    Versions and options
    apt-get clean
    Empty disk caching packets

Services, demons

In the following tutorials, we will install a service (web, ftp, email) also called demons. Debian, Ubuntu and Linux variants thereof are administered via scripts located in / etc / init.d, taking the argument mostly start terms (start), stop (stop), restart (reboot), reload (reload the configuration without restarting). Example: /etc/init.d/apache restart . It must of course be identified as root (super administrator) to perform these operations.

NTP

NTP can synchronize server time with atomic clocks. Debian Etch already exists openntpd. You can equip your system with apt-get install ntp ntpdate . Edit /etc/ntp.conf or /etc/default/ntpdate to verify the configuration and modify the server address with those closest to you then restart the service: /etc/init.d/ntp restart .
Miscellaneous

Install some tools that will be very useful (to do that if it seems appropriate):

apt-get install zip unzip gcc libc6-dev linux-kernel-headers diff wget bzip2 make

To handle character sets and local do not hesitate to invoke:

dpkg-reconfigure locales
End


Viewing all articles
Browse latest Browse all 5

Latest Images

Trending Articles





Latest Images