看板 Linux 關於我們 聯絡資訊
我家裡電腦在 ~/.profile 底下加上下面指令可以成功建起 tunnel nohup autossh -M 23456 -NfR 8888:localhost:22 [email protected] & 帶是在公司一樣的ubuntu 16.04 下無法成功建立 tunnel 後來我用 ps aux | grep '8888' 發現家裡的會有下面兩行 2425 0.0 0.0 6424 88 ? Ss 18:52 0:00 /usr/lib/autossh/autossh -M 23456 -NR 8888:localhost:22 [email protected] 2426 0.0 0.0 46968 5148 ? S 18:52 0:00 /usr/bin/ssh -L 23456:127.0.0.1:23456 -R 23456:127.0.0.1:23457 -NR 8888:localhost:22 [email protected] 可是公司電腦不會出現下面這行 /usr/bin/ssh -L 23456:127.0.0.1:23456 -R 23456:127.0.0.1:23457 -NR 8888:localhost:22 [email protected] 但是我手動下 nohup autossh -M 23456 -NfR 8888:localhost:22 [email protected] & 兩行又有出現可以正常建起 tunnel 請問這問題可能是什麼原因? 謝謝 -- ※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 175.181.227.224 ※ 文章網址: https://www.ptt.cc/bbs/Linux/M.1499425233.A.1A5.html
kenduest: .profile 那是個人登入時候會執行的腳本檔案 07/07 19:02
kenduest: 應該不會有所謂開機時候自己啟動這個功能 07/07 19:02
kenduest: 不過也許你的系統有開機時候啟動X,有自動登入該帳號 07/07 19:03
kenduest: 這類或許可能會執行到?純個人猜測 07/07 19:03
dearlove: 寫在 /etc/rc.local 07/07 19:05
kenduest: /etc/rc.local 之外,若你系統是使用新的 linux 版本 07/07 19:09
kenduest: 有採用 systemd 的話可採用他的運作額外配置方式 07/07 19:10
chang505: 自寫看門狗丟在crontab就好 07/07 19:47
qsort: autossh不是ssh,autossh要是需要ssh來連線,只是autossh 07/11 21:26
qsort: 會檢查ssh結束的return code,再決定要不要重叫ssh 07/11 21:27
qsort: 建議不要用autossh -M的功能,改用ssh ServerAliveInterval 07/11 21:28
qsort: 和ServerAliveCountMax,這個透過ssh session tunnel做ping 07/11 21:29
qsort: pong test, 優點: 少用兩個port, 可以透過strace看ssh是否 07/11 21:30
qsort: nohup也不需要了,autossh有-f可以直接丟背景 07/11 21:31
qsort: 但一定要配合和ssh的-N和key-based authentication 07/11 21:33
qsort: 例如: autossh -f -N -o ServerAliveInterval=15 ip.ip.ip. 07/11 21:35
qsort: 注意: -f的位置一定要出現在ssh的參數之前 07/11 21:36
qsort: "man ssh_config"有說明ServerAliveInterval的用法 07/11 21:39