Connecting to a Remote Server via SSH

Connection to a remote server via SSH

SSH (Secure Shell)is a network protocol that allows you to connect to a remote server and execute commands on it.

Let's learn how to connect to a server and read files:

How to Connect to a Server via SSH

  1. Open the console.
  2. Enter the ssh command and connection details

    ssh username@server_address
    • username — username
    • server_address — IP address or domain name of the server
  3. Enter the password (input characters will not be displayed).

  4. After successful authentication, you will be able to execute commands on the server.

    To end the session, enter the command

    exit

Connect to the test server via the console

$

Host: demo.server

User: admin

Password: password

File System Navigation

In the vast majority of cases, servers use the Linux operating system; commands in Windows may vary slightly. Upon logging in, the user usually lands in the /home/username directory.

To find out the current directory, enter

pwd

To change the directory, enter the cd command and the directory path

cd /path/to/directory

To move up one directory level

cd ..

To display all files and folders in the current directory, enter

ls

Reading Files

To display the contents of a file, enter the cat command and the file path (filename if you are in the same directory)

cat /path/to/file

Files can be very large; for example, if you only need the latest log file entries, it makes sense to request the end of the file

tail -n 30 /path/to/file
  • n — the number of lines to display

Application Log Files

Application log files usually have the .log extension and are often stored in a folder named log, for example

/var/log/application_name/application_name.log
/var/logs/application_name/application_name.log
/var/application_name/log/application_name.log
/app/log/application_name/application_name.log
/app/log/application_name.log

If the log file cannot be found, it is easiest to ask the application developer or DevOps engineer for the path.

Task
Task available to premium users!
Sidebar arrow