0Pricing
Linux Networking & TCP/IP for Developers · Урок

SSH для безопасного удалённого доступа

Настраивайте и защищайте SSH для удалённого доступа к командной строке, передачи файлов и перенаправления портов

«SSH для безопасного удалённого доступа» — бесплатный урок Linux Networking & TCP/IP for Developers на CoddyKit. Это урок 1 из 4. Ты можешь прочитать весь урок бесплатно ниже — а потом практиковать его прямо в браузере с встроенным редактором кода и ИИ-репетитором 24/7. Это часть пути обучения Linux Networking & TCP/IP for Developers, и твой прогресс синхронизируется между веб-версией и приложением CoddyKit. Курс Linux Networking & TCP/IP for Developers содержит 4 уроков всего.

Части этого урока еще не переведены и отображаются на английском.

Introduction to SSH

Secure Shell (SSH) is a powerful network protocol that lets you connect to remote computers securely. It creates an encrypted tunnel between your local machine and a remote server.

SSH is essential for:

  • Executing commands on remote servers.
  • Securely transferring files.
  • Creating secure tunnels for other network services.

It's a foundational tool for managing Linux servers remotely and securely.

How SSH Works

SSH operates on a client-server model. Your local machine acts as the client, and the remote server runs an SSH daemon (the server software).

When you initiate a connection, the client and server perform a cryptographic handshake. This establishes a secure, encrypted channel, protecting all data exchanged from eavesdropping or tampering.

This strong encryption and identity verification make SSH safe to use even over untrusted networks like the internet.

Connecting Remotely

To connect to a remote server, you'll need its IP address or hostname, and a valid username on that server. The basic command is simple:

When connecting for the first time, SSH will prompt you to verify the host's identity and add its fingerprint to your ~/.ssh/known_hosts file. Always verify this fingerprint if possible!

ssh username@hostname_or_ip

SSH Key-Based Authentication

While passwords work, SSH keys offer a more secure and convenient way to authenticate. They eliminate the need to type your password for every connection.

An SSH key pair consists of two parts:

  • A private key: Kept secret on your local machine.
  • A public key: Shared with remote servers you want to access.

During connection, the server uses your public key to encrypt a challenge. Only your private key can decrypt it, proving your identity without ever sending your password over the network.

Generating SSH Keys

You can generate your own SSH key pair on your local machine using the ssh-keygen command. It's recommended to use a strong passphrase to protect your private key.

The command will ask where to save the keys (default is ~/.ssh/id_rsa and ~/.ssh/id_rsa.pub) and for an optional passphrase.

ssh-keygen -t rsa -b 4096 -C "your_email@example.com"

# Example output:
# Generating public/private rsa key pair.
# Enter file in which to save the key (/home/user/.ssh/id_rsa):
# Enter passphrase (empty for no passphrase):
# Enter same passphrase again:
# Your identification has been saved in /home/user/.ssh/id_rsa
# Your public key has been saved in /home/user/.ssh/id_rsa.pub

Deploying Your Public Key

To enable key-based authentication, your public key needs to be copied to the remote server. It should be placed in the ~/.ssh/authorized_keys file within your home directory on the remote server.

The simplest way to do this is using the ssh-copy-id utility:

Alternatively, you can manually copy the contents of your id_rsa.pub file and append it to the remote server's ~/.ssh/authorized_keys file.

ssh-copy-id username@hostname_or_ip

Secure File Transfer with SCP

The Secure Copy Protocol (SCP) allows you to securely copy files and directories between local and remote hosts, or even between two remote hosts.

SCP uses SSH for data transfer and authentication, ensuring your files are encrypted throughout the process.

  • To copy a local file to a remote server:
scp /path/to/local/file.txt user@example.com:/path/to/remote/

SCP: Remote to Local

Similarly, you can easily copy files from a remote server to your local machine using SCP:

  • To copy a remote file to your local machine:

Remember to specify the full path for both source and destination to avoid errors.

scp user@example.com:/path/to/remote/file.txt /path/to/local/

SSH Port Forwarding (Local)

SSH can create secure "tunnels" to forward network traffic. Local port forwarding lets you access a service on a remote network as if it were running on your local machine.

This is extremely useful for accessing services behind a firewall or on an internal network.

Command syntax: ssh -L local_port:target_host:target_port user@ssh_server

Example: Access a web server (port 80) on internal_web_server from your local browser via localhost:8080.

ssh -L 8080:internal_web_server:80 user@jump_host

Quick Check: SSH Features

Which of the following statements about SSH are TRUE?

Recap: SSH for Secure Access

Great job! You've learned the essentials of SSH for secure remote access.

  • We covered basic SSH connection using ssh username@host.
  • Explored SSH key-based authentication, generating keys with ssh-keygen and deploying them with ssh-copy-id.
  • Understood how to securely transfer files using SCP.
  • Learned about local port forwarding to tunnel traffic securely.

SSH is an indispensable tool for any developer or system administrator. Keep practicing these commands to master remote server management!

Часто задаваемые вопросы

Урок «SSH для безопасного удалённого доступа» бесплатный?

Да — полный текст урока «SSH для безопасного удалённого доступа» бесплатно доступен здесь в веб-версии. Чтобы практиковать его интерактивно (встроенный редактор кода и ИИ-репетитор 24/7) и разблокировать остальной курс Linux Networking & TCP/IP for Developers, подпишись на CoddyKit PRO. Курс Linux Networking & TCP/IP for Developers содержит 4 уроков всего.

Чему я научусь в уроке «SSH для безопасного удалённого доступа»?

Настраивайте и защищайте SSH для удалённого доступа к командной строке, передачи файлов и перенаправления портов Ты практикуешь Linux Networking & TCP/IP for Developers с помощью реального кода, который запускаешь прямо в браузере, и ИИ-репетитор 24/7 отвечает на твои вопросы во время урока.

Нужен ли мне опыт, чтобы начать Linux Networking & TCP/IP for Developers?

Предыдущий опыт не требуется. Linux Networking & TCP/IP for Developers на CoddyKit структурирован для всех уровней — от новичков до продвинутых, поэтому ты можешь начать отсюда или с самого начала и учиться в своем темпе. Это урок 1 из 4.

Сколько времени занимает урок «SSH для безопасного удалённого доступа»?

Большинство уроков CoddyKit занимают около 5–10 минут. Каждый из них компактный и интерактивный, поэтому ты постоянно делаешь прогресс и продолжаешь с того же места в веб-версии и приложении.

Можно ли писать и запускать код в этом уроке Linux Networking & TCP/IP for Developers?

Да. Каждый урок Linux Networking & TCP/IP for Developers включает встроенный редактор кода, поэтому ты пишешь и запускаешь реальный код прямо в браузере и получаешь моментальную обратную связь от AI — локальная установка не требуется.

Все уроки этого курса

  1. SSH для безопасного удалённого доступа
  2. Веб-службы HTTP/HTTPS
  3. Службы DHCP и DNS
  4. NTP и службы синхронизации времени
← Назад к Linux Networking & TCP/IP for Developers