Перейти к содержимому

Постоянный сеанс tmux с общим сокетом

0

Я хотел бы, чтобы всегда был сеанс tmux на сокете в / tmp / shared с сеансом 0. Таким образом, я всегда могу подключиться к сеансу через SSH:

ssh user@www.example.com -t tmux -S /tmp/shared attach-session -t 0 

Я хочу, чтобы он был доступен другим пользователям и мог воссоздать себя, если менее знающий или неосторожный пользователь использует выход вместо [ctrl] + d при выходе из сеанса.

Я уверен, что это можно сделать в хрон, но я не знаю, что нет лучшего способа.

1 409 просмотров
Jacob Margason спросил 11 лет назад
J 480

2 ответа

1
Принятый ответ

Creating a socket file owned by selected users mutual group and using a session name would be better then using session number.

/// Create session tmux -S /tmp/shareds new -s sharedsession /// Change ownership to group chgrp mutual_group_name /tmp/shareds /// Run this in other user or ssh session to attach yourself tmux -S /tmp/shareds attach -t sharedsession 

A few ways to check session status:

  1. you can create a cron but it will delay creation of sharedsession because of minimum 1 minute rule.
  2. init.d script to run it as a service, similar to this one
  3. you can install supervisord and use it to auto daemonize your shared session creation script

Last year i used tmate running as a daemon. You can create a tmate server and attached sessions from different machines with using daemonized tmate in them. But i can not guarantee security for this cause i used them in a private network.

mim. ответил 11 лет назад
M 126
0

The following attaches to session 0 or creates a new session:

tmux new-session -t 0 || tmux

I don't think that you can create sessions with a specific session number, so you might want to consider using a session name. However a custom socket may well be good enough for your situation.

I'm assuming here that if session 0 doesn't exist that it will be created.

awatts ответил 11 лет назад
A 316