SSH 跳板机(堡垒机)登录大法

本文介绍如何通过SSH实现从本地主机(localhost)经由认证主机(authhost)登录远程主机(remotehost)的方法,并详细说明了双跳板登录的具体步骤及端口转发的配置过程。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

SSH log into remote host via auth host

A: local host, B: auth host, C: remote host

double SSH

ssh <userb>@<ipb> -p <portb>
[Enter]<pwdb>
[type :]ssh <userc>@<ipc> -p <portc> [default: 22]
[Enter]<pwdc>

SSH port forward

ssh -L <porta>:<ipc>:<portc> <userb>@<ipb> -p <portb>
[Enter]<pwdb>
[open a new terminal]
ssh <userc>@localhost -p <porta>
[Enter]<pwdc>

Note: If you want to put this terminal to background, append the option “-Nf”]
-f means “Requests ssh to go to background just before command execution.”
-N means “Do not execute a remote command.”
if -N omitted, error occurs “Cannot fork into background without a command to execute.” So you have to imply that no cmd is gonna execute. Only pwd is typed in after the port forward cmd.
After this, you continue to type ssh cmd in local terminal.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值