更新时间:2024-03-05 GMT+08:00
分享

如何处理SSH tunnel进程异常?

混合云场景下,监控数据通过ssh tunnel跳板机转发至APM时,该进程异常。此时您可以通过以下方式进行处理。

  1. 使用远程登录工具登录跳板机。
  2. 执行如下命令设置免交互登录。

    ssh-keygen
    cd /root/.ssh/
    cat id_rsa.pub > authorized_keys
    vi /etc/ssh/sshd_config
    设置PubkeyAuthentication的值为yes。
    service sshd restart 

  3. 获取checkSsh.sh脚本,更改配置并设置执行权限。

    1. 获取脚本。

      下载地址:https://icagent-{region}.obs.{region}.myhuaweicloud.com/ICAgent_linux/checkSsh.sh

      各Region下载地址不同,需要将下载地址中的{region}替换为您所在区域。例如华北-北京四区域的下载地址为:

      https://icagent-cn-north-4.obs.cn-north-4.myhuaweicloud.com/ICAgent_linux/checkSsh.sh

    2. 设置执行权限
      chmod +x checkSsh.sh 
    3. 执行checkSsh.sh脚本,参数为ssh命令。
      • 以下命令中的{跳板机ip}、{elbip}和{region}等变量需要替换为实际值。
      • 如果跳板机操作系统为Ubuntu或Debian,则您在执行checkSsh.sh脚本前需要先执行sudo dpkg-reconfigure dash命令并选择“NO”后再执行checkSsh.sh脚本。
      sh checkSsh.sh "ssh -f -N -L {跳板机ip}:8149:{elbip}:8149 -L {跳板机ip}:8102:{elbip}:8102 -L {跳板机ip}:8923:{elbip}:8923 -L {跳板机ip}:30200:{elbip}:30200 -L {跳板机ip}:30201:{elbip}:30201 -L {跳板机ip}:80:icagent-{region}.obs.{region}.myhuaweicloud.com:80 {跳板机ip}"

  4. 设置crontab并周期执行。

    crontab -e 
    */10 * * * * /home/tools/checkSsh.sh ssh -f -N -L {跳板机ip}:8149:{elbip}:8149 -L {跳板机ip}:8102:{elbip}:8102 -L {跳板机ip}:8923:{elbip}:8923 -L {跳板机ip}:30200:{elbip}:30200 -L {跳板机ip}:30201:{elbip}:30201 -L {跳板机ip}:80:icagent-{region}.obs.{region}.myhuaweicloud.com:80 {跳板机ip}
    crond restart
    • 以上命令中的脚本存放目录/home/tools/checkSsh.sh为示例目录,您需要替换为实际存放目录。
    • 以上命令中的10表示以10分钟为周期执行,您可以根据需要进行修改。

分享:

常见使用问题 所有常见问题

more