Вот что умеет SSH!!! Более 9 фичей!!!

3 min read 4 hours ago
Published on Oct 24, 2024 This response is partially generated with the help of AI. It may contain inaccuracies.

Table of Contents

Introduction

This tutorial will guide you through the powerful features of SSH (Secure Shell) using OpenSSH, as demonstrated in the video "Вот что умеет SSH!!! Более 9 фичей!!!" on the Realtime User channel. SSH is an essential tool for secure remote access and file management, and we will explore various functionalities that can enhance your workflow.

Step 1: Access a Remote Server Using Key File

To log into a remote server securely, you can use a key file instead of a password. Follow these steps:

  1. Generate an SSH key pair if you don't have one:
    ssh-keygen -t rsa -b 4096 -C "your_email@example.com"
    
  2. Copy the public key to the remote server:
    ssh-copy-id user@remote_server
    
  3. Connect to the server using the key:
    ssh -i ~/.ssh/id_rsa user@remote_server
    

Step 2: Transfer Files via SSH

You can easily send files to a remote server using the scp command. Here’s how:

  1. To send a file:
    scp /path/to/local/file user@remote_server:/path/to/remote/directory
    
  2. To retrieve a file from the remote server:
    scp user@remote_server:/path/to/remote/file /path/to/local/directory
    

Step 3: Access Remote Files through File Manager

You can mount remote directories using SSHFS for easier file management.

  1. Install SSHFS:
    sudo apt install sshfs
    
  2. Create a mount point:
    mkdir ~/remote_directory
    
  3. Mount the remote directory:
    sshfs user@remote_server:/path/to/remote/directory ~/remote_directory
    
  4. Access files via your file manager.

Step 4: Use a Jump Host for SSH Connections

A jump host allows you to connect to a remote server through an intermediary server.

  1. Use the following command to connect:
    ssh -p 17777 -i ~/.ssh/id_any -J user@jump_host user@target_server
    

Step 5: Set Up a Socks5 Proxy

SSH can be used to create a Socks5 proxy for secure internet browsing.

  1. Start the proxy with the following command:
    ssh -D 1080 -N user@remote_server
    
  2. Configure your web browser to use localhost:1080 as the proxy.

Step 6: Remote Port Forwarding

You can forward a local port to a specific host using SSH.

  1. Use the command below to set up port forwarding:
    ssh -p 12233 -N -L local_port:localhost:remote_port user@publichost.addr
    
  2. Ensure your SSH server allows TCP forwarding by checking /etc/ssh/sshd_config:
    AllowTcpForwarding yes
    

Step 7: Run Remote Applications Locally

You can execute remote applications on your local machine.

  1. Use the following command to run a remote application:
    ssh -X user@remote_server application_name
    

Step 8: Digitally Sign Files

You can sign files to ensure their integrity.

  1. Sign a file:
    ssh-keygen -Y sign -f ~/.ssh/id_rsa -n "file_to_sign"
    
  2. Verify the signature:
    ssh-keygen -Y verify -f ~/.ssh/id_rsa.pub -n "file_to_sign"
    

Step 9: Create an SSH VPN

You can use SSH to tunnel network traffic for a VPN-like experience.

  1. Start the SSH connection with the following command:
    ssh -D 1080 -C -N user@remote_server
    

Step 10: Test SSH Speed

Measure the speed of your SSH connection with the following command:

  1. Install the necessary tool:
    sudo apt update && sudo apt install -y pv
    
  2. Run the speed test:
    yes | pv | ssh user@remote_host "cat /dev/null"
    

Conclusion

In this tutorial, we explored the various functionalities of SSH, including secure access, file transfers, remote application execution, and more. These features can greatly enhance your productivity and security when working with remote servers. For deeper exploration, consider trying out each feature in your own environment to see how they can fit your workflow.