Can attaching to tmux sessions be password protected, similar to gnu screen?
I've been using gnu screen for many years, and I've been looking into switching to tmux.
I can't figure out how to make tmux require a password when attaching to a session. In gnu screen, I use the :password
command to set a password. Then after detach, subsequent attaches to the session using screen -x
requires the password to attach.
How do I configure tmux to do the same? I've done some googling, and I get the impression that this isn't possible. That's a show-stopper for me. I like tmux, but if it doesn't support password-protected session attaches, I can't use it.
password tmux gnu-screen session
add a comment |
I've been using gnu screen for many years, and I've been looking into switching to tmux.
I can't figure out how to make tmux require a password when attaching to a session. In gnu screen, I use the :password
command to set a password. Then after detach, subsequent attaches to the session using screen -x
requires the password to attach.
How do I configure tmux to do the same? I've done some googling, and I get the impression that this isn't possible. That's a show-stopper for me. I like tmux, but if it doesn't support password-protected session attaches, I can't use it.
password tmux gnu-screen session
add a comment |
I've been using gnu screen for many years, and I've been looking into switching to tmux.
I can't figure out how to make tmux require a password when attaching to a session. In gnu screen, I use the :password
command to set a password. Then after detach, subsequent attaches to the session using screen -x
requires the password to attach.
How do I configure tmux to do the same? I've done some googling, and I get the impression that this isn't possible. That's a show-stopper for me. I like tmux, but if it doesn't support password-protected session attaches, I can't use it.
password tmux gnu-screen session
I've been using gnu screen for many years, and I've been looking into switching to tmux.
I can't figure out how to make tmux require a password when attaching to a session. In gnu screen, I use the :password
command to set a password. Then after detach, subsequent attaches to the session using screen -x
requires the password to attach.
How do I configure tmux to do the same? I've done some googling, and I get the impression that this isn't possible. That's a show-stopper for me. I like tmux, but if it doesn't support password-protected session attaches, I can't use it.
password tmux gnu-screen session
password tmux gnu-screen session
edited Jan 1 at 21:46
Rui F Ribeiro
39.4k1479131
39.4k1479131
asked Jan 1 at 19:05
smcdowsmcdow
101
101
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
This isn't possible with tmux yet. You can only lock the terminal so far. The developers argue something about if someone has access to another shell on the system then you are toast anyway.
However, I've come up with a quick solution using file permissions and attributes to lock things up. I've put it together into 3 bash files which you would have to add to your $PATH.
start.sh
#!/bin/bash
if [[ ! -d ~/.tmux-sessions ]]; then
mkdir ~/.tmux-sessions
fi
tmux -S ~/.tmux-sessions/secure
Once you want to exit your session, do so normally with ctrl+b,d -- then you would want to run lock.sh shown below.
lock.sh
#!/bin/bash
chmod 000 ~/.tmux-sessions
sudo chattr +i ~/.tmux-sessions
sudo -k
This will lock the socket used to connect to tmux. Nobody will be able to access it until you remove the immutable attribute from the socket directory and change the permissions back to normal. Luckily we can create a script for this, too:
attach.sh
#!/bin/bash
sudo chattr -i .tmux-sessions
chmod 770 .tmux-sessions
tmux -S ~/.tmux-sessions/secure attach
With that you should just be able to run attach.sh, which will ask you for your user password to re-open.
Hope this hack helps!
For just locking your terminal.
First you need to have vlock installed.
sudo apt install vlock
or whatever package manager command you use.
Then you set tmux to use vlock
echo "set-option -g lock-command vlock" >> ~/.tmux.conf
Then when you are in tmux, you can do:
ctrl+b,:lock-session[enter]
That will lock the terminal. The caveat is someone could still attach to the session from another terminal. I'm looking to see if there is a way to prevent that as well.
add a comment |
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "106"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f491908%2fcan-attaching-to-tmux-sessions-be-password-protected-similar-to-gnu-screen%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
This isn't possible with tmux yet. You can only lock the terminal so far. The developers argue something about if someone has access to another shell on the system then you are toast anyway.
However, I've come up with a quick solution using file permissions and attributes to lock things up. I've put it together into 3 bash files which you would have to add to your $PATH.
start.sh
#!/bin/bash
if [[ ! -d ~/.tmux-sessions ]]; then
mkdir ~/.tmux-sessions
fi
tmux -S ~/.tmux-sessions/secure
Once you want to exit your session, do so normally with ctrl+b,d -- then you would want to run lock.sh shown below.
lock.sh
#!/bin/bash
chmod 000 ~/.tmux-sessions
sudo chattr +i ~/.tmux-sessions
sudo -k
This will lock the socket used to connect to tmux. Nobody will be able to access it until you remove the immutable attribute from the socket directory and change the permissions back to normal. Luckily we can create a script for this, too:
attach.sh
#!/bin/bash
sudo chattr -i .tmux-sessions
chmod 770 .tmux-sessions
tmux -S ~/.tmux-sessions/secure attach
With that you should just be able to run attach.sh, which will ask you for your user password to re-open.
Hope this hack helps!
For just locking your terminal.
First you need to have vlock installed.
sudo apt install vlock
or whatever package manager command you use.
Then you set tmux to use vlock
echo "set-option -g lock-command vlock" >> ~/.tmux.conf
Then when you are in tmux, you can do:
ctrl+b,:lock-session[enter]
That will lock the terminal. The caveat is someone could still attach to the session from another terminal. I'm looking to see if there is a way to prevent that as well.
add a comment |
This isn't possible with tmux yet. You can only lock the terminal so far. The developers argue something about if someone has access to another shell on the system then you are toast anyway.
However, I've come up with a quick solution using file permissions and attributes to lock things up. I've put it together into 3 bash files which you would have to add to your $PATH.
start.sh
#!/bin/bash
if [[ ! -d ~/.tmux-sessions ]]; then
mkdir ~/.tmux-sessions
fi
tmux -S ~/.tmux-sessions/secure
Once you want to exit your session, do so normally with ctrl+b,d -- then you would want to run lock.sh shown below.
lock.sh
#!/bin/bash
chmod 000 ~/.tmux-sessions
sudo chattr +i ~/.tmux-sessions
sudo -k
This will lock the socket used to connect to tmux. Nobody will be able to access it until you remove the immutable attribute from the socket directory and change the permissions back to normal. Luckily we can create a script for this, too:
attach.sh
#!/bin/bash
sudo chattr -i .tmux-sessions
chmod 770 .tmux-sessions
tmux -S ~/.tmux-sessions/secure attach
With that you should just be able to run attach.sh, which will ask you for your user password to re-open.
Hope this hack helps!
For just locking your terminal.
First you need to have vlock installed.
sudo apt install vlock
or whatever package manager command you use.
Then you set tmux to use vlock
echo "set-option -g lock-command vlock" >> ~/.tmux.conf
Then when you are in tmux, you can do:
ctrl+b,:lock-session[enter]
That will lock the terminal. The caveat is someone could still attach to the session from another terminal. I'm looking to see if there is a way to prevent that as well.
add a comment |
This isn't possible with tmux yet. You can only lock the terminal so far. The developers argue something about if someone has access to another shell on the system then you are toast anyway.
However, I've come up with a quick solution using file permissions and attributes to lock things up. I've put it together into 3 bash files which you would have to add to your $PATH.
start.sh
#!/bin/bash
if [[ ! -d ~/.tmux-sessions ]]; then
mkdir ~/.tmux-sessions
fi
tmux -S ~/.tmux-sessions/secure
Once you want to exit your session, do so normally with ctrl+b,d -- then you would want to run lock.sh shown below.
lock.sh
#!/bin/bash
chmod 000 ~/.tmux-sessions
sudo chattr +i ~/.tmux-sessions
sudo -k
This will lock the socket used to connect to tmux. Nobody will be able to access it until you remove the immutable attribute from the socket directory and change the permissions back to normal. Luckily we can create a script for this, too:
attach.sh
#!/bin/bash
sudo chattr -i .tmux-sessions
chmod 770 .tmux-sessions
tmux -S ~/.tmux-sessions/secure attach
With that you should just be able to run attach.sh, which will ask you for your user password to re-open.
Hope this hack helps!
For just locking your terminal.
First you need to have vlock installed.
sudo apt install vlock
or whatever package manager command you use.
Then you set tmux to use vlock
echo "set-option -g lock-command vlock" >> ~/.tmux.conf
Then when you are in tmux, you can do:
ctrl+b,:lock-session[enter]
That will lock the terminal. The caveat is someone could still attach to the session from another terminal. I'm looking to see if there is a way to prevent that as well.
This isn't possible with tmux yet. You can only lock the terminal so far. The developers argue something about if someone has access to another shell on the system then you are toast anyway.
However, I've come up with a quick solution using file permissions and attributes to lock things up. I've put it together into 3 bash files which you would have to add to your $PATH.
start.sh
#!/bin/bash
if [[ ! -d ~/.tmux-sessions ]]; then
mkdir ~/.tmux-sessions
fi
tmux -S ~/.tmux-sessions/secure
Once you want to exit your session, do so normally with ctrl+b,d -- then you would want to run lock.sh shown below.
lock.sh
#!/bin/bash
chmod 000 ~/.tmux-sessions
sudo chattr +i ~/.tmux-sessions
sudo -k
This will lock the socket used to connect to tmux. Nobody will be able to access it until you remove the immutable attribute from the socket directory and change the permissions back to normal. Luckily we can create a script for this, too:
attach.sh
#!/bin/bash
sudo chattr -i .tmux-sessions
chmod 770 .tmux-sessions
tmux -S ~/.tmux-sessions/secure attach
With that you should just be able to run attach.sh, which will ask you for your user password to re-open.
Hope this hack helps!
For just locking your terminal.
First you need to have vlock installed.
sudo apt install vlock
or whatever package manager command you use.
Then you set tmux to use vlock
echo "set-option -g lock-command vlock" >> ~/.tmux.conf
Then when you are in tmux, you can do:
ctrl+b,:lock-session[enter]
That will lock the terminal. The caveat is someone could still attach to the session from another terminal. I'm looking to see if there is a way to prevent that as well.
edited Jan 2 at 1:49
answered Jan 2 at 1:13
Jeff AJeff A
3216
3216
add a comment |
add a comment |
Thanks for contributing an answer to Unix & Linux Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f491908%2fcan-attaching-to-tmux-sessions-be-password-protected-similar-to-gnu-screen%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown