IntroductionSSH is typically used for logging into remote servers so you have shell access to do maintenance, read your email, restart services, or whatever administration you require. SSH also offers some other native services, such as file copy (usingscp and sftp) and remote command execution (using ssh with a command on the command line after the hostname). Whenever we SSH from one machine to another, we establish a secure encrypted session. This first article in this SSH series[1] looked at properly verifying a server's host key, so that we can be sure that no attacker is able to perform a man-in-the-middle attack and gain access to read or manipulate what we do in that session. Other articles in this series looked at removing the need for static passwords using SSH user identities[2], and then using ssh-agent[3] to automate the task of typing passphrases. SSH also has a wonderful feature called SSH Port Forwarding, sometimes called SSH Tunneling, which allows you to establish a secure SSH session and then tunnel arbitrary TCP connections through it. Tunnels can be created at any time, with almost no effort and no programming, which makes them very appealing. In this article we look at SSH Port Forwarding in detail, as it is a very useful but often misunderstood technology. SSH Port Forwarding can be used for secure communications in a myriad of different ways. Let's start with an example.
LocalForward ExampleSay you have a mail client on your desktop, and currently use it to get your email from your mail server via POP, the Post Office Protocol, on port 110.[4] You may want to protect your POP connection for several reasons, such as keeping your password from going across the line in the clear[5], or just to make sure no one's sniffing the email you're downloading.Normally, your mail client will establish a TCP connection to the mail server on port 110, supply your username and password, and download your email. You can try this yourself using
xahria@desktop$ nc mailserver 110 +OK SuperDuper POP3 mail server (mailserver.my_isp.net) ready. USER xahria +OK PASS twinnies +OK User successfully logged on. LIST +OK 48 1420253 1 1689 2 1359 3 59905 ... 47 3476 48 3925 . QUIT +OK SuperDuper POP3 mail server signing off. xahria@desktop$
We can wrap this TCP connection inside an SSH session using SSH Port Forwarding. If you have SSH access to the machine that offers your service (POP, port 110 in this case) then SSH to it. If you don't, you can SSH to a server on the same network if the network is trusted. (See the security implications of port forwarding later in this article.) In this case, let's assume we don't have SSH access to the mail server, but we can log into a shell server on the same network, and create a tunnel for our cleartext POP connection:
# first, show that nothing's listening on our local machine on port 9999: xahria@desktop$ nc localhost 9999 Connection refused. xahria@desktop$ ssh -L 9999:mailserver:110 shellserver xahria@shellserver's password: ******** xahria@shellserver$ hostname shellserver
From a different window on your desktop machine, connect to your local machine (
xahria@desktop$ nc localhost 9999 +OK SuperDuper POP3 mail server (mailserver.my_isp.net) ready. USER xahria +OK PASS twinnies ...
Before we connected to the shellserver with SSH, nothing was listening on port 9999 on our desktop - once we'd logged in to the mail server with our tunnel, this port was bound by our SSH process, and the TCP connection to local port 9999 was magically tunneled through SSH to the other side. Let's describe how this works in detail, using the example above.
SSH Port Forward DebuggingLet's see it in action by using the verbose option tossh:
xahria@desktop$ ssh -v -L 9999:mailserver:110 shellserver debug1: Reading configuration data /etc/ssh/ssh_config debug1: Rhosts Authentication disabled, originating port will not be trusted. debug1: Connecting to shellserver [296.62.257.251] port 22. debug1: Connection established. debug1: identity file /home/bri/.ssh/identity type 0 debug1: identity file /home/bri/.ssh/id_rsa type 1 debug1: identity file /home/bri/.ssh/id_dsa type 2 ... debug1: Next authentication method: password xahria@shellserver's password: ******** debug1: Authentication succeeded (password). debug1: Connections to local port 9999 forwarded to remote address localhost:110 debug1: Local forwarding listening on 127.0.0.1 port 9999. debug1: channel 0: new [client-session] debug1: Entering interactive session. debug1: channel 0: request pty-req debug1: channel 0: request shell xahria@shellserver$ As you can see, there's a brief mention of port 9999 being bound and available for tunneling. We haven't made a connection to this port yet, so no tunnel is active yet. You can use the
xahria@shellserver$ (enter)
xahria@shellserver$ (enter)
xahria@shellserver$ (enter)
xahria@shellserver$ ~#
The following connections are open:
#1 client-session (t4 r0 i0/0 o0/0 fd 5/6)
xahria@shellserver$
You can see that there's only one connection, our actual SSH session from which we're typing those unix commands. Now, in a different window if we do a
xahria@shellserver$ (enter)
xahria@shellserver$ ~#
The following connections are open:
#1 client-session (t4 r0 i0/0 o0/0 fd 5/6)
#2 direct-tcpip: listening port 9999 for mailserver port 110,
connect from 127.0.0.1 port 42789 (t4 r1 i0/0
o0/0 fd 8/8)
You can see that now we have both the SSH session we're using, plus a tunnel, the second entry. It tells you all you need to know about the connection -- it came from our local machine (127.0.0.1) source port 42789, which we could look up with
RemoteForward ExampleSSH Forwards actually come in two flavours. The one I've shown above is a local forward, where the ssh client machine is listening for new connections to be tunneled. A Remote Forward is just the opposite - a tunnel initiated on the server side that goes back through the client machine.The classic example of using a Remote Forward goes something like this. You're at work, and the VPN access is going to be down for maintenance for the weekend. However you really have some important work to do, but you'd rather work from the comfort of your desk at home, rather than being stuck at work all weekend. There's no way for you to SSH to your work desktop because it's behind the firewall. Before you leave for the evening, you SSH from your work desktop back to your home network. Your
lainee@work$ tail ~/.ssh/config
Host home-with-tunnel
Hostname 204.225.288.29
RemoteForward 2222:localhost:22
User laineeboo
lainee@work$ ssh home-with-tunnel
laineeboo@204.225.228.29's password: ********
laineeboo@home$ ping -i 5 127.0.0.1
PING 127.0.0.1 (127.0.0.1): 56 data bytes
64 bytes from 127.0.0.1: icmp_seq=0 ttl=255 time=0.1 ms
64 bytes from 127.0.0.1: icmp_seq=1 ttl=255 time=0.2 ms
64 bytes from 127.0.0.1: icmp_seq=2 ttl=255 time=0.2 ms
...
We've set up a tunnel using the Later that evening, we can sit down on our home machine and see that we're logged in:
laineeboo@home$ last -1 laineeboo pts/18 firewall.my_work.com Tue Nov 23 22:28 still logged in laineeboo@home$ ps -t pts/18 PID TTY TIME CMD 3794 pts/18 00:00:00 ksh 4027 pts/18 00:00:00 ping -i 5 127.0.0.1 Now comes the payoff - our tunnel is listening on our home machine on port 2222, and will be tunneled back through the corporate firewall to our work machine's port 22. So to SSH to work from home, since we have our tunnel ready, we simply point
laineboo@home$ ssh -p 2222 lainee@localhost lainee@localhost's password: ******** lainee@work$ Success! Port Forwarding Cheat SheetRemembering how to specify the kind of SSH Forward you want is sometimes tricky. Hopefully, the following table will make it a bit easier.
Forwards can be confusing - we typically think of connections as being made up of four things - the local IP and port, and the remote IP and port. In the forward definition you create, you only have three things because the first port is always either the SSH client or server machine, and thus isn't specified.
Port Forward SecurityPort forwards bind a port on either the ssh client (Local Forwards) or ssh server (Remote Forwards). With a default installation, the port will only be bound on the localhost interface, 127.0.0.1. This means that the tunnel is only available to someone on the machine where that port is listening.In general, you don't want to allow other machines to contact your SSH tunnel so this is the correct setting. If you want to allow these ports to be available to any machine, then use one of the following:
The other important thing you must remember is that the data connection is only encrypted inside the SSH connection. If your
desktop$ ssh -L 8080:www.example.com:80 somemachine then any connection to We'll see how you can put further limits on port forwards in a future article, such as rejecting or limiting them based on the SSH Pubkeys/Identity that is used for authentication. | |||||||||||||||||||||||||
NOTES:
[1] SSH Host Key Protection: http://www.securityfocus.com/infocus/1806 [2] SSH User Identities: http://www.securityfocus.com/infocus/1810 [3] SSH and ssh-agent: http://www.securityfocus.com/infocus/1812 [4] Some POP server software offers SSL-encrypted POP, by negotiating SSL using STARTTLS on port 110, or wrapped entirely in SSL on port 995. For this example, however, let's assume you have a non-SSL aware POP server. [5] Some POP servers support alternate authentication methods, such as S/Key or challenge response, which can keep your password from going across the network. [6] Unsniffable options would be localhost, 127.0.0.1 (or any 127/8 address on most unix-like systems) or any local IP address - these should all go through the local machine's TCP/IP stack without hitting the network card at all, and thus would be as secure as the network stack itself. View more articles by Brian Hatch |
相关推荐
SSH端口转发失败?手把手教你解决remote port forwarding报错问题
本文详细解析SSH远程端口转发(remote port forwarding)失败的常见原因及解决方案,涵盖网络可达性验证、权限配置、服务端参数调整等关键排查步骤,并提供autossh保持连接、多级跳转等高级技巧,帮助开发者高效解决内网穿透问题。
SSH连接错误
用xshell客户端连接主机出现错误: ssh 用户名@ip_address [port] 官方文档上的提示: "Could not connect to 'hostname' (port 22): Connection failed." Check if the host machine is ready for connection and the port
2024高项范文-论项目成本管理
例如,在需求分析和设计阶段,安排了较多经验丰富的人员,确保基础工作的高质量完成,同时也避免了后续因需求变更等问题导致的时间和成本浪费。虽然项目进度略有延迟,但通过有效的成本管理和调整,最终在可控的成本范围内完成了项目,并且软件的质量也得到了保障。通过这个案例可以看出,在项目成本管理过程中,要紧密结合时间管理,根据实际情况灵活调整策略,注重风险的防范和应对,才能实现时间和成本的平衡,确保项目的成功。资源规划是成本基准形成的基础。识别和评估项目中的成本风险,并制定相应的应对措施,以降低风险对项目成本的影响。
连接SSH失败的原因以及方法
一、检查用户名密码 连接失败时可以先检查验证信息,步骤如下: 1、运行软件,在会话管理中找到连接失败的会话。右键单击会话名,点击属性。 图1:查看属性 2、在弹出的对话框点击用户身份验证,看输入的信息和服务器上设置的用户名密码是否一致。如果输入的验证信息有误,重新输入后点击连接即可。 图2:检查验证信息 二、 检查服务器网络 先检查是否是网络的问题。按快捷键Win+R,在弹出的对话框中输入cmd。 图3:运行cmd命令 点击确定运行。在cmd窗口输入ping一下..
麒麟v10(ky10.x86_64)升级——openssl-3.2.2、openssh-9.8p1
执行命令: make -j 4 && make install 这里要等待一段时间,等待编译完成。执行命令: ./configure --prefix=/usr/local/src/zlilb。执行命令: ./config --prefix=/usr/local/src/openssl。执行命令: make -j 4 && make test && make install。执行命令: make -j 4 && make install。执行命令: /etc/init.d/sshd restart。
LaTeX参考文献格式apsrev4-1,增加文献标题
APS的LaTeX参考文献格式apsrev4-1是隐藏标题的,如果想要出现标题,需要更改apsrev4-1.bst文件内容 在apsrev4-1.bst文件靠后部分,定义不同类型文献格式的地方,将article类型的内容替换为, FUNCTION {article} { output.bibitem format.authors booktitle empty$ { "author" output.check }{ output } if$ author format.
解决 ssh登录失败的原因
但出现以下报错:Unable to negotiate with 10.188.5.86 port 22: no matching host key type found. Their offer: ssh-rsa,ssh-dss。的时候会将每个你访问过计算机的公钥(public key)都记录在/.ssh/known_hosts。如果公钥不同,OpenSSH会发出警告,信息报错类似错误,如当前情况。解决办法:参考如下方式进行连接 ssh -oHostKeyAlgorithms=+ssh-
IDEA中Maven工具栏与命令执行全攻略:高效开发必备技巧
IntelliJ IDEA 作为强大的 Java 开发工具,其 Maven 功能独具优势。Maven 工具栏位于工作区右侧,图标功能丰富,涵盖项目导入、源码处理、依赖操作等。执行 Maven 命令有多种途径,Run Anything 窗口可输入或选目标执行,上下文菜单能右键运行目标,还可创建运行配置,指定命令参数后运行,为开发者高效管理 Maven 项目、便捷执行命令提供有力支持。
本地端口转发Local Port Forwarding(SSH命令)
本地端口转发Local Port Forwarding(SSH命令)
Rust 语言入门
Rust 使 对您的编辑或工具或代码所在的位置没有特定要求,因此 如果您更喜欢使用集成开发环境 (IDE) 而不是 命令行,请随意使用您最喜欢的 IDE。对于简单的程序来说,只编译 是可以的,但作为你的项目 增长,您将需要管理所有选项并轻松共享您的 法典。接下来,我们将向您介绍 Cargo 工具,它将帮助您编写 真实世界的 Rust 程序。现在您已经安装了 Rust,是时候编写您的第一个 Rust 程序了。这不重要 到你的代码所在的 Rust,但对于本书中的练习和项目, 我们建议在你的主目录中创建一个。
win10和Mac上安装Freesurfer
Mac安装Freesurfer 软件下载地址 可以根据官方给出的demo视频一步一步下载
ssh port forwarding
SSH: Port Forwarding 1.正向隧道-隧道监听本地port,为普通活动提供安全连接 ssh -qTfnN -L port:host:hostport -l user remote_ip 2.反向隧道----隧道监听远程port,突破防火墙提供服务 ssh
51单片机超声波测距数码管显示并报警(Proteus 仿真)
HC-SR04超声波 实物图 使用方法 1、给TRIG端口至少10us 的高电平信号 2、模块自动发送 8 个 40khz 的方波,自动检测是否有信号返回 3、有信号返回,ECHO端口会输出一个高电平,高电平持续的时间就是超声波从发射到返回的时间 计算的话这里就不考虑温度的影响直接用声速340m/s Proteus仿真 HC-SR04可以用Proteus中的SRF04代替 下面附上代码 ...
ssh port forwarding(ssh端口转发)
SSH的的Port Forward,中文可以称为端口转发,是SSH的一项非常重要的功能。它可以建立一条安全的SSH通道,并把任意的TCP连接放到这条通道中。下面仔细就仔细讨论SSH的这种非常有用的功能。 SSH Tunnel有三种,分别是本地Local(ssh -NfL),远程Remote(ssh -NfR),动态Dynamic(ssh -NfD)。(含义参考man ss
基于STM32L4XX、HAL库的AD7124模数转换器ADC驱动程序设计
/ 检查ID是否正确 (AD7124-4/AD7124-8有不同的ID)// 转换为电压值 (假设使用内部2.5V基准)// 构造读命令: 1(R/W) + 1(0) + 6(寄存器地址)// 构造写命令: 0(R/W) + 1(0) + 6(寄存器地址).config = 0, // 使用配置0。内置可编程增益放大器(PGA):1-128倍。// 读取ADC数据。// 读取当前ADC控制寄存器。// 检查数据是否就绪。// 写回ADC控制寄存器。// 初始化AD7124。
全球国家地区城市数据
MySQL全球国家地区城市数据报。。。。。。。。。。。。
基于MobaXterm配置ssh隧道(port forwarding)
文章目录1. 打开 MobaXterm,在工具中找到 MobaSSHtunnal,点击建立新的隧道2. 代理配置3. 添加私钥4. 点击启动/停止启动/关闭代理 1. 打开 MobaXterm,在工具中找到 MobaSSHtunnal,点击建立新的隧道 2. 代理配置 3. 添加私钥 4. 点击启动/停止启动/关闭代理 ...
Camera2Demo
在Camera2 的基础上进行封装,使得Camera2一堆初始化逻辑与Activity分离,降低耦合度,完成预览拍照并保存的操作
SSH端口转发(port forwarding)基础知识
1.介绍 我们知道SSH的一个重要作用就是连接远程机器(比如一台服务器)来实现对远程机器的操作。 但是除此之外,SSH还可以用于构建机器之间的通信中介。 举个简单的例子,我们有时会在本地(localhost)运行某些程序或应用,而每个程序或者应用都会运行在一个指定的端口下(port), 我们可以直接通过监听(listen)该端口来查看其他用户向该应用发出的请求(request)并做出响应(response)。但是如果我们希望对本地端口的请求,由远程机器来进行响应,换句话说,我们希望能将发送给本地端口的
TMS_WebGMaps_1.9.8.0_Full_Source
TMS_WebGMaps_1.9.8.0_Full_Source 全源码 delphi cbuilder
OV9734 DATASHEET,完整规格书
OV9734完整规格书,包括电气参数,尺寸规格,寄存器配置表等
【工具使用】怎么设置SSH隧道(Port Forwarding)
- SSH隧道(SSH tunneling)是一个在一个客户端和服务器之间创建加密的SSH连接的方法,它通过能够被转播的端口进行。 - SSH传送(SSH forwarding)对于运送网络中的服务数据很有用,它使用未加密的协议,比如VNC或者FTP,来获取受到地域限制的内容,或者绕开中间的防火墙。基本上,你可以传送任何TCP端口和打通通道通过一个安全的SSH连接。 - 这里有三种类型的SSH端口传送: - 局部端口传送:从客户端主机到SSH服务器主机传送连接,之后再到达目标主机端口。 - 远程端口
How to Create SSH Tunneling (Port Forwarding)
#Linux #Command #SSH
ssh端口转发(port forwarding)
<br /><br />SSH(Secure Shell)有很多功能,它既可以代替Telnet,又可以为FTP、POP、甚至为PPP<br />提供一个安全的"通道".<br />从ssh这个命令可以看出一些端倪,通常形式为:<br />ssh ... [command]<br />可以直接在远程主机执行命令,当忽略command时相当于一个安全的telnet.<br />其次,sshd类似于xinetd,为许多其他服务监听连接,当有连接到达时fork一下服务程序就<br />可以了,sftpd大概就是如此
A short guide to SSH port forwarding
A short guide to SSH port forwarding SSH port forwarding, or TCP/IP connection tunneling, is a process whereby a TCP/IP connection that would otherwise be insecure is tunneled through a secure SSH link, thus protecting the tunneled connection from netwo..
SSH Port Forwarding (SSH Tunneling)
Sintax: ssh -L localport:host:hostport user@ssh_server -N where: -L - port forwarding parameters (see below) localport - local port (chose a port that is not in use by other ser...
SSH port forwarding - socks server 转载
利用SSH port forwarding来做代理,运行这样的命令:ssh -D 7070 -N -C-o PubkeyAuthentication=no<username>@<hostname>From:http://www.debian-administration.org/article/SSH_dynamic_port_forwarding_with_SOC...
SSH Tunnel扫盲(ssh port forwarding端口转发)
SSH的的Port Forward,中文可以称为端口转发,是SSH的一项非常重要的功能。它可以建立一条安全的SSH通道,并把任意的TCP连接放到这条通道中。下面仔细就仔细讨论SSH的这种非常有用的功能。 SSH Tunnel有三种,分别是本地Local(ssh -NfL),远程Remote(ssh -NfR),动态Dynamic(ssh -NfD)。(含义参考man ssh)
ssh-remote-port-forwarding
1、ssh免密码登录(A登录到B) 1.1、在A上执行并在~/.ssh下生成id_rsa和id_rsa.pub两个文件 ssh-keygen -t rsa -P '' 1.2、拷贝id_rsa.pub到B的~/.ssh/authorized_keys文件中 scp ~/.ssh/id_rsa.pub tato@192.168.1.100:~/.ssh/authorize...
212



被折叠的 条评论
为什么被折叠?



