zoukankan      html  css  js  c++  java
  • autossh 使用

    centos7下配置为服务

    编辑服务配置文件

    cat  /usr/lib/systemd/system/autossh.service
    
    [Unit]
    Description=Auto SSH Tunnel
    After=network-online.target
    [Service]
    User=yoo
    Type=simple
    ExecStart=/bin/autossh -p 22 -M 12340 -NR '*:12345:127.0.0.1:22' pi@yourip -i /home/yoo/.ssh/id_rsa
    ExecReload=/bin/kill -HUP $MAINPID
    ExecStop=/bin/kill -TERM $MAINPID
    KillMode=process
    Restart=always
    [Install]
    WantedBy=multi-user.target
    WantedBy=graphical.target
    

    开机启动与取消

    [root@centos7proxy ~]# systemctl disable  autossh.service
    Removed symlink /etc/systemd/system/multi-user.target.wants/autossh.service.
    Removed symlink /etc/systemd/system/graphical.target.wants/autossh.service.
    [root@centos7proxy ~]# systemctl enable  autossh.service
    Created symlink from /etc/systemd/system/multi-user.target.wants/autossh.service to /usr/lib/systemd/system/autossh.service.
    Created symlink from /etc/systemd/system/graphical.target.wants/autossh.service to /usr/lib/systemd/system/autossh.service.
    

    命令式使用

    映射远程主机防火墙之后的端口到本机

    ssh -L localhost:3306:localhost:3306 test.domain
    autossh -NL localhost:3306:localhost:3306 test.domain
    

    映射本机端口到远程主机

    ssh -p 22 -qngfNTR 8080:127.0.0.1:8080 test.domain
    autossh -p 22 -M 6777 -NR 8080:127.0.0.1:8080 test.domain
  • 相关阅读:
    杨辉三角
    手动实现md5加密
    戳气球
    重构字符串
    四数相加 II
    背包问题 II
    组合总和 IV
    背包问题 V
    背包问题
    Win 10安装Python及环境变量配置
  • 原文地址:https://www.cnblogs.com/BlackSwanYucatan/p/10125836.html
Copyright © 2011-2022 走看看