Linux connect to server via ssh

How to connect to a Linux server via SSH

SSH – also known as “Secure Socket Shell“, is a protocol that provides users with a secure way to access a remote Linux server. “SSH” is used by anyone who needs to securely control a computer remotely, as well as system and network administrators. “Secure Shell” (SSH) provides public key and password authentication, as well as encrypted communication between two computers connected via the Internet. The software consists of an SSH server running on the VDS and a client running on the user’s end. The software provides all the necessary functionality for working with a Linux VDS server, from remote access, file transfer and ending with TCP port redirection. It is the de facto standard for remote interaction with Linux servers. The SSH server and client are always included in a bootable Linux installation. It remains only to connect remotely.

Connecting to the server via SSH from Windows

One of the more commonly used methods is to connect via PuTTY.

What is PuTTY

PuTTY is an SSH client available for Windows and available on Windows computers with MCECS support. In addition, it is freely available on the Internet and can be downloaded for use on your personal computer from: http://www.chiark.greenend.org.uk/~sgtatham/putty/

Launch PuTTY and a window will appear, i.e. the program itself. It looks like the screenshot below.

  1. Enter the IP of the server you want to connect to.
  2. Click the Open button.
  3. If this is your first time trying to connect to this host, PuTTY will warn you that it cannot guarantee that the computer you are connecting to, is who it claims to be. Click Yes to store the key in the PuTTY cache.
  4. Enter your login and password. When ordering a server from us, you get access to the root superuser. Accordingly, you must specify the root login and he’s password, which is located in the “Instruction” section in your account.
    Important. Do not be confused, when entering a password, asterisks or dots indicating the password are not visible!

Connecting to the server via SSH protocol from Windows, Linux and macOS with a built-in SSH client

To connect from Windows, Linux or macOS we must open:

  1. CMD (command prompt in Windows)
  2. Or terminal in Linux OS and macOS.

Then, enter the following command, accept the conditions, write “yes” and press Enter.

Читайте также:  Linux postfix smtp server

By default, the SSH port is always 22 and CMD also determines it itself.

After we wrote “yes”, press Enter and continue, specify the password, press Enter again and enter the server.

Connecting to the server via SSH protocol from Windows, Linux and macOS with Termius

What is Termius

Termius — is a great free SSH client with which you can easily manage all your servers. You connect directly to the server in the normal way (ssh [email protected]) or you can add them to “Termius” to favourites and easily connect to each one in the future with just one click.

Its advantage is availability on all systems: Windows, macOS, Linux, iOS and Android, and for most of them there is a free version. The paid version is pretty good too, but not required. For regular use, the free version is perfect.

Step one. We have to download and install “Termius”.
You can download from the link: https://www.termius.com/download

After we have downloaded and launched “Termius” it will be automatically installed.
Now you need to create an account as it is required. Specify the data and click on “Singup with email”

After registration, in the initial page, specify the IP, then click on the “Create host” button

On the new page, we specify:

The name of the server, so that it is easy to recognize which service is in question – if you have several of them.

Click on the checkbox and save.

After that, double-click on the config that you saved, then click “Add and continue”

We have connected to the server and we can start working now.

A big advantage of this SSH client is the built-in SFTP client. You will not need to use WinSCP, FileZilla or other software in this case to access server files.

Источник

Connecting to a Remote Server Over SSH on Linux

Estamos traduciendo nuestros guías y tutoriales al Español. Es posible que usted esté viendo una traducción generada automáticamente. Estamos trabajando con traductores profesionales para verificar las traducciones de nuestro sitio web. Este proyecto es un trabajo en curso.

A secure shell (SSH) is used for secure communication between devices. When most people refer to SSH, it is within the context of connecting from a local computer to a remote server, commonly for administration tasks related to website hosting.

This article covers the basics of connecting to a remote server (such as a Linode) over SSH on a Linux system.

Before You Begin

  1. Ensure you have a Linux server with an SSH server (like OpenSSH) installed. Most Linux distributions have an SSH server preinstalled. If you wish to deploy a new server, follow the Creating a Compute Instance guide to create a Linode.
  2. Your local computer needs an SSH client that can be used through a terminal application. Most modern Linux distributions have SSH installed and ready to use.
Читайте также:  Xiaomi pc suite linux

Open the Terminal

On your local computer, open the terminal application you wish to use. The terminal allows you to access your operating system’s shell environment and run programs through the command line.

If you’re using Linux through the command line, you are already in the terminal and can skip this section. If you are using Linux through a desktop environment (a graphical interface), you’ll need to locate and open the terminal application that comes with your Linux distribution and desktop environment. In most cases, pressing Ctrl + Alt + T on your keyboard opens the default terminal.

  • Gnome: The default terminal emulator is Gnome Terminal. Gnome is the default desktop environment for Ubuntu.
  • KDE: The default terminal emulator is Konsole. KDE is the default desktop environment for Manjaro.

If this key combination does not work for you, other instructions for opening a terminal vary depending on the Linux distribution and desktop environment you are running. In many cases, you’ll want to open the application search tool and search for “terminal”.

Connecting to the Remote Server Over SSH

  1. Within the terminal, enter the following command, replacing [username] with the username of the remote user and [ip-address] with the IP address or domain name of the remote server.

If the server’s SSH port is something other than 22, it needs to be specified in the SSH command. To do this, use the -p option as shown in the command below. Replace [port-number] with the port number that the remote SSH server is using.

The authenticity of host ‘example.com (93.184.216.34)’ can't be established. ECDSA key fingerprint is SHA256:d029f87e3d80f8fd9b1be67c7426b4cc1ff47b4a9d0a84. Are you sure you want to continue connecting (yes/no)?

You can verify the fingerprint by following the instructions on the Verifying the Authenticity of a Remote Server guide.

If you recently rebuilt your server, you might receive an error message when you try to connect. This happens when the remote host key changes. To fix this, revoke the key for that IP address.

Warning: Permanently added 'example' (ECDSA) to the list of known hosts.

Once you have successfully connected, your terminal should be using the remote shell environment for the server. Your command prompt should now show the username and hostname configured for the server. You can now run any commands that you have available on that server. This includes many of the basic Linux commands, such as ls , cd , rm , and those covered in Using the Terminal guide. Getting to know these commands will help you navigate around your server.

Ending the SSH Session

After you are done, log out of the session by typing exit . The terminal then shows something similar to:

logout Connection to 93.184.216.34 closed.

At this point, the shell prompt returns to the one for the local workstation and the terminal application can be closed if it’s no longer needed.

Читайте также:  Снес винду поставил линукс

Sending Commands Over SSH

Instead of using SSH to open your remote server’s console, you can run commands on your server without leaving your local shell environment. This can enable you to quickly run commands both locally and remotely in the same terminal window.

Sending a Single Command

To run a single command on your remote server, use the following command. Replace [username] with the username of the remote user, [ip-address] with the IP address or domain name of the remote server, and [command] with the command you wish to run.

As an example, running ssh me@192.0.2.0 ls lists all the files in the home directory of the user called me . This can be useful to find the uptime of the server ( ssh me@192.0.2.0 uptime ) or maybe determine its Linux distribution and version ( ssh me@192.0.2.0 lsb_release -a ).

Sending Multiple Commands

To run multiple commands on your remote server (one after the other), use the following command. Replace [command-1], [command-2], and [command-3] with the commands you wish to run.

The commands should be separated by a semi-colon ( ; ) and all of the commands together should be surrounded by double quotation marks ( » ). For example, if you wanted to create a file named bar.txt in a directory called foo within the user me’s home directory, run: ssh me@192.0.2.0 «mkdir foo; cd foo; touch bar.txt .

Using sudo

It’s recommended to disable root access over SSH and only log in to your remote server through a limited user account. However, some commands require elevated privileges, which can usually be accomplished by prepending the command with sudo . If you attempt to do this while running commands directly through the SSH command, you may receive an error such as “no tty present” or there isn’t a “stable CLI interface”. To run the sudo command in these instances, use the -t option, which forces a psuedo-terminal allocation. For example, to update your packages on a Debian-based system, run ssh linode@example.com -t «sudo apt update» .

Going Further

Troubleshooting SSH Connection Issues

If SSH isn’t connecting you to your Linode, you may need to investigate the state of your server. See the guide Troubleshooting SSH for assistance.

Increasing Security

  • Now that you can connect from your Linux machine to the Linode over SSH, save not only time but also make the connection even more secure by using SSH public key authentication. For more information, see SSH add keys.
  • See the “Harden SSH Access” section of Setting Up and Securing a Compute Instance guide to review how to secure SSH on the server’s side, and the Advanced SSH Server Security for more information on making it even more secure.

This page was originally published on Friday, June 25, 2021.

Источник

Оцените статью
Adblock
detector