[小技巧] autossh to maintain ssh session and screen

date
Jan 7, 2024
slug
tip-autossh-screen-session
status
Published
summary
小技巧
tags
tip
type
Post
URL

Problem & Summary

Solution

alias autossh-orc-phoenix-free2="autossh_port_ip 22022 129.146.136.100"


function autossh_port_ip() {
     if [ $# -ne 2 ]; then
         echo "Usage: autossh_ip [port] [ip]"
         return 1
     fi

     local port=$1
     local ip=$2

     autossh -M 0 -o 'ServerAliveInterval 30' -o 'ServerAliveCountMax 300' -p "$port" root@"$ip" -t 'screen -d -R Screen1'
 }
notion image

Screenshots

 

© Ying Bun 2021 - 2024