SSH access

SSH (Secure SHell) is a network protocol that allows you to connect to a remote server and execute commands on it, download files. The key feature is encryption of transmitted information. By default, command interpreter bash is implemented on hosting.

1. Information for connection
2. Working with hosting using Midnight Commander
3. Work with hosting from command line:


 

1. Information for connection

You can get information for connecting to the server via SSH and SFTP in the FTP and SSH section of the hosting control panel.

  • Server address (host): ssh.login.nichost.ru, where «login» is the unique name of the hosting service (indicated in the upper right part of the control panel).
  • SSH user name (login): login.
  • To get the SSH user password, click the Reset password (Сбросить пароль) button. The new password will be displayed in a pop-up window. To send the password to your contact email address, check the Send password to email box (Выслать пароль на почту).

For connection with the hosting server via SSH, install ssh-client on your computer. To upload files on hosting use SFTP client.

If the message «cannot allocate memory» appears when connecting via SSH, this means that all the memory available for your plan is occupied on your hosting. To free it up, you can temporarily stop the web server and disable the tasks of the task scheduler in the Web server management (Управление веб-сервером) section of the hosting control panel. We also recommend that you read the Using Hosting Resources article.
 

2. Working with hosting using Midnight Commander

Midnight Commander is a two-panel file manager. It has a built-in text editor.

To run Midnight Commander connect to hosting via SSH and enter command

mc

Basic hot keys:

  • F1: Help;
  • F3: Built-in file viewer;
  • F4: Built-in text editor;
  • F5: Copy file;
  • F6: Remove (rename) file;
  • F8: Delete file:
  • F9: Display drop-down menu;
  • F10: Program exit;
  • Tab: Switching between panels
  • Insert: Check file for operations with several files, for example, for copying.

     

3. Work with hosting from command line

Help

To get help information on the command you are interested in, type the following in the command line:

man command

to finish work with the help click on «q».

The brief note about the command may be received by running it with setting --help or -h:

command --help

Moving along file system

Display current directory:

pwd

Go to user home directory:

cd

Go to tmp directory located in the current directory:

cd tmp

Go to catalog by full path /home/login/sitename.ru/docs (root catalog of website name.ru):

cd /home/login/sitename.ru/docs

Go to parent directory (on a higher level):

cd ..

Go to previous directory:

cd -

Creation and deletion of files and directories.

Create new directory foo in the current directory:

mkdir foo

Create structure of directories foo/bar/baz in the current directory:

mkdir -p foo/bar/baz

Create directory foo in the current directory. The directory shall be empty:

rmdir foo

Delete directory foo with all files and subdirectories:

rm -rf foo

Create blank file foo:

touch foo

Deleted file foo:

rm foo

Viewing and editing file contents

View the contents of the text file (log-file of the website) (Click «q» to exit):

less /var/log/sitename.ru.access_log

Open file foo in text editor:

mcedit foo

Copying and moving files

Copy file foo into file bar:

cp foo bar

Copy the contents of directory "old" into directory "new":

cp old/* new/

Rename file foo to file bar:

mv foo bar

Move file foo to existing directory bar under baz name:

mv foo bar/baz

Changing access rights

Recommended access rights on hosting for files 644 (rw-rw-rw-), for directories 755 (rwxr-xr-x).

Make file foo executable:

chmod 755 foo

Make file foo read-only:

chmod 444 foo

Changing access rights for all directories, contained in directory foo on 755:

find foo -type d -exec chmod 755 {} \;

Changing access rights for all directories, contained in directory foo on 644:

find foo -type f -exec chmod 644 {} \;

Processes management

Show information about processes in real time (Press «q» to exit):

top

Show detailed information about all processes in progress:

ps auxww

Finish process work by its process identifier (PID) 1234:

kill 1234

Finish process work by its name:

killall apache2

Work with archives

Create archive of docs directory:

tar -czf archive.tar.gz docs

Unpack archive.tar.gz:

tar -xzf archive.tgz

Unpack archive.zip:

unzip archive.zip

Unpack archive.rar:

unrar x archive.rar

Unpack archive.gz:

gunzip archive.gz

Files search

Among website files find those containing text «login.mysql» (server address to access database):

grep -R "login.mysql" sitename.ru/docs

Find in the current directory and subdirectories files index.php:

find . -name index.php

Всё ещё остались вопросы?