Junior — Middle
Применял ли ты SSH-туннелирование для безопасной передачи данных?
sobes.tech AI
Answer from AI
SSH tunneling is a method to create a secure connection between a local and a remote machine, allowing data to be transmitted through an encrypted channel. In Python, libraries like Paramiko or external utilities are often used to create SSH tunnels.
Example of using an SSH tunnel to redirect a local port to a remote server:
import paramiko
import socket
ssh = paramiko.SSHClient()
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
ssh.connect('remote_host', username='user', password='pass')
# An example of creating a tunnel can be implemented via forward_tunnel, but it's easier to use external tools
# Alternatively, you can use the ssh command from Python:
import subprocess
subprocess.Popen(['ssh', '-L', 'local_port:remote_host:remote_port', 'user@remote_host'])
SSH tunneling is useful for secure access to internal resources, bypassing firewalls, and protecting transmitted data.