Tee all SSH Session Output (by default)ssh session never exits cleanlyPrevent tmux from starting up on...
What does a comma signify in inorganic chemistry?
Adding things to bunches of things vs multiplication
Programming a recursive formula into Mathematica and find the nth position in the sequence
How do I answer an interview question about how to handle a hard deadline I won't be able to meet?
Unconventional examples of mathematical modelling
What allows us to use imaginary numbers?
What's the point of writing that I know will never be used or read?
What exactly happened to the 18 crew members who were reported as "missing" in "Q Who"?
A reccomended structured approach to self studying music theory for songwriting
Why does this image of cyclocarbon look like a nonagon?
How to render "have ideas above his station" into German
Would getting a natural 20 with a penalty still count as a critical hit?
Will some rockets really collapse under their own weight?
Does knowing that the exponent is in a certain range help solving discrete log?
My new Acer Aspire 7 doesn't have a Legacy Boot option, what can I do to get it?
Rotate List by K places
Icon is not displayed in lwc
global variant of csname…endcsname
Gofer work in exchange for Letter of Recommendation
What is the purpose/function of this power inductor in parallel?
Are there any OR challenges that are similar to kaggle's competitions?
Are there any rules on how characters go from 0th to 1st level in a class?
Parse a simple key=value config file in C
Polar contour plot in Mathematica?
Tee all SSH Session Output (by default)
ssh session never exits cleanlyPrevent tmux from starting up on SSHImmortal SSH SessionRunning a “scheduled”/delayed script as sudo on server, via ssh - and right before ssh exitAdd a static text layer/bar in terminalensure that all tmux session terminate when SSH session endsdetecting a shared ssh sessionssh routing between multiple linux system containers transparently
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ margin-bottom:0;
}
Currently I am trying to do something similar to what PuTTY does on Windows. I want to capture ssh session info. I want to be able to see stdout in a log file based on the hour, and separate the logs based on host. Now tee works well but you will always need to remember to type out tee and the date and directory. Thats just not really practical. Does someone know of a way to do what I am asking? I looked into adding the Local command option to my ssh configs but that as you would imagine it is not(cannot) be used to capture output as it appears to run the command after the ssh session starts.
ssh
New contributor
add a comment |
Currently I am trying to do something similar to what PuTTY does on Windows. I want to capture ssh session info. I want to be able to see stdout in a log file based on the hour, and separate the logs based on host. Now tee works well but you will always need to remember to type out tee and the date and directory. Thats just not really practical. Does someone know of a way to do what I am asking? I looked into adding the Local command option to my ssh configs but that as you would imagine it is not(cannot) be used to capture output as it appears to run the command after the ssh session starts.
ssh
New contributor
add a comment |
Currently I am trying to do something similar to what PuTTY does on Windows. I want to capture ssh session info. I want to be able to see stdout in a log file based on the hour, and separate the logs based on host. Now tee works well but you will always need to remember to type out tee and the date and directory. Thats just not really practical. Does someone know of a way to do what I am asking? I looked into adding the Local command option to my ssh configs but that as you would imagine it is not(cannot) be used to capture output as it appears to run the command after the ssh session starts.
ssh
New contributor
Currently I am trying to do something similar to what PuTTY does on Windows. I want to capture ssh session info. I want to be able to see stdout in a log file based on the hour, and separate the logs based on host. Now tee works well but you will always need to remember to type out tee and the date and directory. Thats just not really practical. Does someone know of a way to do what I am asking? I looked into adding the Local command option to my ssh configs but that as you would imagine it is not(cannot) be used to capture output as it appears to run the command after the ssh session starts.
ssh
ssh
New contributor
New contributor
edited 2 days ago
Yilmaz
1331 silver badge11 bronze badges
1331 silver badge11 bronze badges
New contributor
asked 2 days ago
DaemonSlayer2048DaemonSlayer2048
61 bronze badge
61 bronze badge
New contributor
New contributor
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
You can create a wrapper that you would use instead of ssh
command. It could be:
tssh() { ssh "$@" | tee "$(date +%m_%Y_%H:%M:%S)"; }
You can now use tssh
with all options you would normally use with
ssh
. SSH session will be logged to a file, for example
08_2019_16:43:50
. See man date
for explanation of +
format
specifiers.
However, it's harder to embed host name in the name of the output log
file. You can use a wrapper like that but you need to remember to
always pass host as the first parameter:
tssh()
{
if [ ! "$#" -eq 1 ]
then
printf "Error: Host missingn" >&2
return 0
fi
ssh "$@" | tee "$1_$(date +%m_%Y_%H:%M:%S)"
}
For example:
$ tssh localhost -vv
$ logout
Output log file will contain hostname in its name, for example:
localhost_08_2019_16:47:41
Thats pretty clean, I like it. I think I can ake it a bit further and maybe make a folder per host and place the log file in that folder. Just for some simple house keeping. A little mkdir -p would handle new hosts too. Thank you Arkadiusz, that should help me get started.
– DaemonSlayer2048
yesterday
Ok. You can now mark this question as answered to let other users know your problem is solved.
– Arkadiusz Drabczyk
yesterday
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
});
}
});
DaemonSlayer2048 is a new contributor. Be nice, and check out our Code of Conduct.
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%2f535738%2ftee-all-ssh-session-output-by-default%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
You can create a wrapper that you would use instead of ssh
command. It could be:
tssh() { ssh "$@" | tee "$(date +%m_%Y_%H:%M:%S)"; }
You can now use tssh
with all options you would normally use with
ssh
. SSH session will be logged to a file, for example
08_2019_16:43:50
. See man date
for explanation of +
format
specifiers.
However, it's harder to embed host name in the name of the output log
file. You can use a wrapper like that but you need to remember to
always pass host as the first parameter:
tssh()
{
if [ ! "$#" -eq 1 ]
then
printf "Error: Host missingn" >&2
return 0
fi
ssh "$@" | tee "$1_$(date +%m_%Y_%H:%M:%S)"
}
For example:
$ tssh localhost -vv
$ logout
Output log file will contain hostname in its name, for example:
localhost_08_2019_16:47:41
Thats pretty clean, I like it. I think I can ake it a bit further and maybe make a folder per host and place the log file in that folder. Just for some simple house keeping. A little mkdir -p would handle new hosts too. Thank you Arkadiusz, that should help me get started.
– DaemonSlayer2048
yesterday
Ok. You can now mark this question as answered to let other users know your problem is solved.
– Arkadiusz Drabczyk
yesterday
add a comment |
You can create a wrapper that you would use instead of ssh
command. It could be:
tssh() { ssh "$@" | tee "$(date +%m_%Y_%H:%M:%S)"; }
You can now use tssh
with all options you would normally use with
ssh
. SSH session will be logged to a file, for example
08_2019_16:43:50
. See man date
for explanation of +
format
specifiers.
However, it's harder to embed host name in the name of the output log
file. You can use a wrapper like that but you need to remember to
always pass host as the first parameter:
tssh()
{
if [ ! "$#" -eq 1 ]
then
printf "Error: Host missingn" >&2
return 0
fi
ssh "$@" | tee "$1_$(date +%m_%Y_%H:%M:%S)"
}
For example:
$ tssh localhost -vv
$ logout
Output log file will contain hostname in its name, for example:
localhost_08_2019_16:47:41
Thats pretty clean, I like it. I think I can ake it a bit further and maybe make a folder per host and place the log file in that folder. Just for some simple house keeping. A little mkdir -p would handle new hosts too. Thank you Arkadiusz, that should help me get started.
– DaemonSlayer2048
yesterday
Ok. You can now mark this question as answered to let other users know your problem is solved.
– Arkadiusz Drabczyk
yesterday
add a comment |
You can create a wrapper that you would use instead of ssh
command. It could be:
tssh() { ssh "$@" | tee "$(date +%m_%Y_%H:%M:%S)"; }
You can now use tssh
with all options you would normally use with
ssh
. SSH session will be logged to a file, for example
08_2019_16:43:50
. See man date
for explanation of +
format
specifiers.
However, it's harder to embed host name in the name of the output log
file. You can use a wrapper like that but you need to remember to
always pass host as the first parameter:
tssh()
{
if [ ! "$#" -eq 1 ]
then
printf "Error: Host missingn" >&2
return 0
fi
ssh "$@" | tee "$1_$(date +%m_%Y_%H:%M:%S)"
}
For example:
$ tssh localhost -vv
$ logout
Output log file will contain hostname in its name, for example:
localhost_08_2019_16:47:41
You can create a wrapper that you would use instead of ssh
command. It could be:
tssh() { ssh "$@" | tee "$(date +%m_%Y_%H:%M:%S)"; }
You can now use tssh
with all options you would normally use with
ssh
. SSH session will be logged to a file, for example
08_2019_16:43:50
. See man date
for explanation of +
format
specifiers.
However, it's harder to embed host name in the name of the output log
file. You can use a wrapper like that but you need to remember to
always pass host as the first parameter:
tssh()
{
if [ ! "$#" -eq 1 ]
then
printf "Error: Host missingn" >&2
return 0
fi
ssh "$@" | tee "$1_$(date +%m_%Y_%H:%M:%S)"
}
For example:
$ tssh localhost -vv
$ logout
Output log file will contain hostname in its name, for example:
localhost_08_2019_16:47:41
edited 2 days ago
answered 2 days ago
Arkadiusz DrabczykArkadiusz Drabczyk
8,8353 gold badges20 silver badges36 bronze badges
8,8353 gold badges20 silver badges36 bronze badges
Thats pretty clean, I like it. I think I can ake it a bit further and maybe make a folder per host and place the log file in that folder. Just for some simple house keeping. A little mkdir -p would handle new hosts too. Thank you Arkadiusz, that should help me get started.
– DaemonSlayer2048
yesterday
Ok. You can now mark this question as answered to let other users know your problem is solved.
– Arkadiusz Drabczyk
yesterday
add a comment |
Thats pretty clean, I like it. I think I can ake it a bit further and maybe make a folder per host and place the log file in that folder. Just for some simple house keeping. A little mkdir -p would handle new hosts too. Thank you Arkadiusz, that should help me get started.
– DaemonSlayer2048
yesterday
Ok. You can now mark this question as answered to let other users know your problem is solved.
– Arkadiusz Drabczyk
yesterday
Thats pretty clean, I like it. I think I can ake it a bit further and maybe make a folder per host and place the log file in that folder. Just for some simple house keeping. A little mkdir -p would handle new hosts too. Thank you Arkadiusz, that should help me get started.
– DaemonSlayer2048
yesterday
Thats pretty clean, I like it. I think I can ake it a bit further and maybe make a folder per host and place the log file in that folder. Just for some simple house keeping. A little mkdir -p would handle new hosts too. Thank you Arkadiusz, that should help me get started.
– DaemonSlayer2048
yesterday
Ok. You can now mark this question as answered to let other users know your problem is solved.
– Arkadiusz Drabczyk
yesterday
Ok. You can now mark this question as answered to let other users know your problem is solved.
– Arkadiusz Drabczyk
yesterday
add a comment |
DaemonSlayer2048 is a new contributor. Be nice, and check out our Code of Conduct.
DaemonSlayer2048 is a new contributor. Be nice, and check out our Code of Conduct.
DaemonSlayer2048 is a new contributor. Be nice, and check out our Code of Conduct.
DaemonSlayer2048 is a new contributor. Be nice, and check out our Code of Conduct.
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%2f535738%2ftee-all-ssh-session-output-by-default%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