Вот что умеет SSH!!! Более 9 фичей!!!
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:
- Generate an SSH key pair if you don't have one:
ssh-keygen -t rsa -b 4096 -C "your_email@example.com"
- Copy the public key to the remote server:
ssh-copy-id user@remote_server
- 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:
- To send a file:
scp /path/to/local/file user@remote_server:/path/to/remote/directory
- 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.
- Install SSHFS:
sudo apt install sshfs
- Create a mount point:
mkdir ~/remote_directory
- Mount the remote directory:
sshfs user@remote_server:/path/to/remote/directory ~/remote_directory
- 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.
- 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.
- Start the proxy with the following command:
ssh -D 1080 -N user@remote_server
- 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.
- Use the command below to set up port forwarding:
ssh -p 12233 -N -L local_port:localhost:remote_port user@publichost.addr
- 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.
- 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.
- Sign a file:
ssh-keygen -Y sign -f ~/.ssh/id_rsa -n "file_to_sign"
- 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.
- 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:
- Install the necessary tool:
sudo apt update && sudo apt install -y pv
- 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.