专题:OpenSSH tunneling
SSH tunneling 相关
参考資料:http://www.ibm.com/developerworks/cn/linux/l-cn-sshforward/
本地端口转发:
- 适用场景:发起端可以连接 SSH_server_host 端的 ssh 服务,但无法与最终目标 goal_host 的程序直接通信,而 SSH_server_host 可以
- 命令格式:ssh [-g] -L <local_port>:<goal_host>:<goal_port> username@<SSH_server_host>
- local_port:最初发起连接的主机端口号
- goal_host:最终目标主机的 IP 或 主机名,可以与 SSH_server_host 为同一台机器(此时 goal_host 通常设置为 localhost 或 127.0.0.1)
- goal_port:最终目标主机的端口号
- SSH_server_host:负責 SSH 转发的中间主机
- -g:此选项允许其它主机远程连接至第一台主机的 local_port 端口上,相当于进一步増加通信节点
远程端口转发:
- 适用场景:发起端无法连接 SSH_server_host 端的 ssh 服务(如:发起端是外网主机,但 SSH_server_host 是 nat 之后的内网主机),但反向连接是允许的,而且 SSH_server_host 可以与最终目标 goal_host 上的程序直接通信
- 命令格式:ssh [-g] -R <remote_port>:<goal_host>:<goal_port> username@<SSH_server_host>
- remote_host:最初发起连接的主机端口号,此处的 remote 是相对 SSH_server_host 而言的,因为这个操作需要在 SSH_server_host 上完成
- goal_host:最终目标主机的 IP 或 主机名,可以是操作此命令的本机
- goal_port:最终目标主机的端口号
- SSH_server_host:此处指 最初发起连接的主机 IP 或 主机名,因为此时的 ssh 连接是由中间主机发出的,最初的主机允当 ssh 服务器的角色
目标主机:
/*C 语言版*/
#include <sys/types.h>
#include <sys/wait.h>
#include <unistd.h>
#include <stdlib.h> int
main(void) {
daemon(0, 0);
char *Argv[] = {"ssh", "-2", "-N", "-R", "9527:localhost:22", "fh@fanhui.f3322.net", NULL};
pid_t Pid;
Label:Pid = fork();
if (Pid == ) {
execvp("ssh", Argv);
}
else if(Pid > ) {
waitpid(Pid, NULL, );
goto Label;
}
else {
exit();
}
}
#!/bin/bash
#dynamic domain name: fanhui.f3322.net
#URL: http://www.pubyun.com http://www.3322.net Keep_Alive() {
Ops="ssh -2 -N -f -R 9527:localhost:22 fh@fanhui.f3322.net"
#仅使用第二版 ssh 协议(-2),建立转发遂道但不登陆控制台(-N),强制后台运行从而取消占用控制台(-f)
while :
do
count=$(ps ax | grep -c $Ops)
if [[ $count -lt ]]
then
su fh -c $Ops
fi
sleep 300s
done
} Keep_Alive
云端( SSH 中转站):
#!/bin/bash
GetIp="http://members.3322.org/dyndns/getip"
while :
do
lynx -mime_header -auth=kitex:aibbigql "http://members.3322.net/dyndns/update?system=dyndns&hostname=fanhui.f3322.net" >/dev/null
Ip_0=$(curl $GetIp)
sleep 600s
Ip_1=$(curl $GetIp) while [[ $Ip_1 -eq $Ip_0 ]]
do
sleep 600s
Ip_1=$(curl $GetIp)
done done
专题:OpenSSH tunneling的更多相关文章
- 开源服务专题之------sshd服务安装管理及配置文件理解和安全调优
本专题我将讨论一下开源服务,随着开源社区的日趋丰富,开源软件.开源服务,已经成为人类的一种公共资源,发展势头可谓一日千里,所以不可不知.SSHD服务,在我们的linux服务器上经常用到,很重要,涉及到 ...
- RHEL5.8设置OpenSSH的X11 Forwarding功能
X11的Forwarding功能需要在SSH中进行设置,RedHat Enterprise Linux5.8默认使用的而是OpenSSH,现将设置方法记录如下: OpenSSH配置文件路径: /etc ...
- openssh
http://www.openssh.com/ OpenSSH is a FREE version of the SSH connectivity tools that technical users ...
- 升级openssh基于openssl
OpenSSH is the premier connectivity tool for remote login with the SSH protocol. It encrypts all tra ...
- 在windows中安装OpenSSH,无密码登录,永远不断线
到这里下载最新安装包:https://github.com/PowerShell/Win32-OpenSSH/releases下载下来解压,然后用管理员打开服务器自带的PowerShell,运行下列命 ...
- How to do SSH Tunneling (Port Forwarding)
How to do SSH Tunneling (Port Forwarding) In this post we will see how ssh works?, what is SSH tunne ...
- 2016年中国微信小程序专题研究报告
2016年12月29日,全球领先的移动互联网第三方数据挖掘和分析机构iiMedia Research(艾媒咨询)权威首发<2016年中国微信小程序专题研究报告>. 报告显示,82.6%手机 ...
- [.NET领域驱动设计实战系列]专题二:结合领域驱动设计的面向服务架构来搭建网上书店
一.前言 在前面专题一中,我已经介绍了我写这系列文章的初衷了.由于dax.net中的DDD框架和Byteart Retail案例并没有对其形成过程做一步步分析,而是把整个DDD的实现案例展现给我们,这 ...
- Ubantu【第一篇】:Ubantu中openssh连接
h3 { color: rgb(255, 255, 255); background-color: rgb(30,144,255); padding: 3px; margin: 10px 0px } ...
随机推荐
- JS-JSDoc
http://usejsdoc.org/ 生成 JSDoc 格式的注释: sublime:安装 DocBlockr VSCode:自带 JSDoc 插件
- sql审核工具调研安装-sqlAdvisor和soar
sql审核工具调研 基于soar的sql审核查询平台: https://github.com/beiketianzhuang/data-platform-soar 1.美团工具sqlAdvisor工 ...
- Openstack组件部署 — Keystone Install & Create service entity and API endpoints
目录 目录 前文列表 Install and configure Prerequisites 先决条件 Create the database for identity service 生成一个随机数 ...
- Java学习之面向对象特性-----封装
面向对象特性一.封装(Encapsulation)封装:是指隐藏对象的属性和实现细节,仅对外提供公共访问方式.好处: 将变化隔离 便于使用 提高复用性 提高安全性封装原则: 将不需要对外提供的内容都隐 ...
- Linux中的特殊权限s、t、i、a
文件权限除了r.w.x外还有s.t.i.a权限:s:文件属主和组设置SUID和GUID,文件在被设置了s权限后将以root身份执行.在设置s权限时文件属主.属组必须先设置相应的x权限,否则s权限并不能 ...
- VMware新建虚拟机之后的初始化工作
一.开启网络功能(后面的ifcfg-ens33自身系统不同) vi /etc/sysconfig/network-scripts/ifcfg-ens33 ONBOOT=yes systemctl re ...
- Springboot+mybatis+dbcp+mysql简单集成
1.添加依赖 <dependency> <groupId>org.mybatis.spring.boot</groupId> <artifactId>m ...
- 一步一步学Vue(六)https://www.cnblogs.com/Johnzhang/p/7242640.html
一步一步学Vue(六):https://www.cnblogs.com/Johnzhang/p/7237065.html 路由 一步一步学Vue(七):https://www.cnblogs.com ...
- mac 完全卸载vscode
原文分隔线====================== while writing go this morning, I found that the wrong code are not under ...
- Ubuntu16.04+cuda9.0安装教程
1.安装NVIDIA驱动 首先去官网(http://www.nvidia.cn/Download/index.aspx?lang=cn)查找适配自己电脑GPU的驱动,我的电脑驱动版本如下: 执行如下语 ...