Using the output of a command to generate an ssh login
I've got a script that I like a lot which generates a two-hopper ssh + port forwarded command.
ssh -N -f -o 'ControlMaster Auto' -o 'ControlPath /tmp/gimme_access' -o 'ControlPersist 1m' -L 6473:33.22.0.0:22 -i /home/sink/.ssh/id_dsa -o 'UserKnownHostsFile /home/sink/.ssh/known_hosts' -p 6000 sink@33.22.177.16 ; ssh -p 6473 -l noc -i /home/my_boy/.ssh/id_rsa -o 'StrictHostKeyChecking no' 127.0.0.1
this gets me on a number of disparate gizmos and I could re-rewrite it to just log me on to those machines, but I prefer that the command just output the connection string.
Is there anything that I can pipe the command that generates the above string and leave me logged in. I tried just piping to bash, but that logged me out right away.
bash ssh pipe
|
show 1 more comment
I've got a script that I like a lot which generates a two-hopper ssh + port forwarded command.
ssh -N -f -o 'ControlMaster Auto' -o 'ControlPath /tmp/gimme_access' -o 'ControlPersist 1m' -L 6473:33.22.0.0:22 -i /home/sink/.ssh/id_dsa -o 'UserKnownHostsFile /home/sink/.ssh/known_hosts' -p 6000 sink@33.22.177.16 ; ssh -p 6473 -l noc -i /home/my_boy/.ssh/id_rsa -o 'StrictHostKeyChecking no' 127.0.0.1
this gets me on a number of disparate gizmos and I could re-rewrite it to just log me on to those machines, but I prefer that the command just output the connection string.
Is there anything that I can pipe the command that generates the above string and leave me logged in. I tried just piping to bash, but that logged me out right away.
bash ssh pipe
Can't you justeval
the string?
– nohillside
Dec 19 '18 at 19:52
@nohillside "| eval" leaves me with ssh'ed in with a locked up console
– Peter Turner
Dec 19 '18 at 19:54
eval $string
:-)
– nohillside
Dec 19 '18 at 19:55
Or probably rathereval $(command-which-produces-string)
– nohillside
Dec 19 '18 at 19:56
@nohillside , that'll do ! sweet - thanks. You want to make that an answer or is this too dumb of a question for a person who thinks they "know unix" to ask?
– Peter Turner
Dec 19 '18 at 19:57
|
show 1 more comment
I've got a script that I like a lot which generates a two-hopper ssh + port forwarded command.
ssh -N -f -o 'ControlMaster Auto' -o 'ControlPath /tmp/gimme_access' -o 'ControlPersist 1m' -L 6473:33.22.0.0:22 -i /home/sink/.ssh/id_dsa -o 'UserKnownHostsFile /home/sink/.ssh/known_hosts' -p 6000 sink@33.22.177.16 ; ssh -p 6473 -l noc -i /home/my_boy/.ssh/id_rsa -o 'StrictHostKeyChecking no' 127.0.0.1
this gets me on a number of disparate gizmos and I could re-rewrite it to just log me on to those machines, but I prefer that the command just output the connection string.
Is there anything that I can pipe the command that generates the above string and leave me logged in. I tried just piping to bash, but that logged me out right away.
bash ssh pipe
I've got a script that I like a lot which generates a two-hopper ssh + port forwarded command.
ssh -N -f -o 'ControlMaster Auto' -o 'ControlPath /tmp/gimme_access' -o 'ControlPersist 1m' -L 6473:33.22.0.0:22 -i /home/sink/.ssh/id_dsa -o 'UserKnownHostsFile /home/sink/.ssh/known_hosts' -p 6000 sink@33.22.177.16 ; ssh -p 6473 -l noc -i /home/my_boy/.ssh/id_rsa -o 'StrictHostKeyChecking no' 127.0.0.1
this gets me on a number of disparate gizmos and I could re-rewrite it to just log me on to those machines, but I prefer that the command just output the connection string.
Is there anything that I can pipe the command that generates the above string and leave me logged in. I tried just piping to bash, but that logged me out right away.
bash ssh pipe
bash ssh pipe
asked Dec 19 '18 at 19:51
Peter Turner
5631825
5631825
Can't you justeval
the string?
– nohillside
Dec 19 '18 at 19:52
@nohillside "| eval" leaves me with ssh'ed in with a locked up console
– Peter Turner
Dec 19 '18 at 19:54
eval $string
:-)
– nohillside
Dec 19 '18 at 19:55
Or probably rathereval $(command-which-produces-string)
– nohillside
Dec 19 '18 at 19:56
@nohillside , that'll do ! sweet - thanks. You want to make that an answer or is this too dumb of a question for a person who thinks they "know unix" to ask?
– Peter Turner
Dec 19 '18 at 19:57
|
show 1 more comment
Can't you justeval
the string?
– nohillside
Dec 19 '18 at 19:52
@nohillside "| eval" leaves me with ssh'ed in with a locked up console
– Peter Turner
Dec 19 '18 at 19:54
eval $string
:-)
– nohillside
Dec 19 '18 at 19:55
Or probably rathereval $(command-which-produces-string)
– nohillside
Dec 19 '18 at 19:56
@nohillside , that'll do ! sweet - thanks. You want to make that an answer or is this too dumb of a question for a person who thinks they "know unix" to ask?
– Peter Turner
Dec 19 '18 at 19:57
Can't you just
eval
the string?– nohillside
Dec 19 '18 at 19:52
Can't you just
eval
the string?– nohillside
Dec 19 '18 at 19:52
@nohillside "| eval" leaves me with ssh'ed in with a locked up console
– Peter Turner
Dec 19 '18 at 19:54
@nohillside "| eval" leaves me with ssh'ed in with a locked up console
– Peter Turner
Dec 19 '18 at 19:54
eval $string
:-)– nohillside
Dec 19 '18 at 19:55
eval $string
:-)– nohillside
Dec 19 '18 at 19:55
Or probably rather
eval $(command-which-produces-string)
– nohillside
Dec 19 '18 at 19:56
Or probably rather
eval $(command-which-produces-string)
– nohillside
Dec 19 '18 at 19:56
@nohillside , that'll do ! sweet - thanks. You want to make that an answer or is this too dumb of a question for a person who thinks they "know unix" to ask?
– Peter Turner
Dec 19 '18 at 19:57
@nohillside , that'll do ! sweet - thanks. You want to make that an answer or is this too dumb of a question for a person who thinks they "know unix" to ask?
– Peter Turner
Dec 19 '18 at 19:57
|
show 1 more comment
1 Answer
1
active
oldest
votes
You can use eval
to run a command stored in a string (or based on the output of another program):
eval 'echo Hello World'
eval $(magic-ssh-commmand-generator)
From man bash
:
eval [arg ...]
The args are read and concatenated together into a single command.
This command is then read and executed by the shell, and its exit status
is returned as the value of eval. If there are no args, or only null
arguments, eval returns 0.
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%2f489996%2fusing-the-output-of-a-command-to-generate-an-ssh-login%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 use eval
to run a command stored in a string (or based on the output of another program):
eval 'echo Hello World'
eval $(magic-ssh-commmand-generator)
From man bash
:
eval [arg ...]
The args are read and concatenated together into a single command.
This command is then read and executed by the shell, and its exit status
is returned as the value of eval. If there are no args, or only null
arguments, eval returns 0.
add a comment |
You can use eval
to run a command stored in a string (or based on the output of another program):
eval 'echo Hello World'
eval $(magic-ssh-commmand-generator)
From man bash
:
eval [arg ...]
The args are read and concatenated together into a single command.
This command is then read and executed by the shell, and its exit status
is returned as the value of eval. If there are no args, or only null
arguments, eval returns 0.
add a comment |
You can use eval
to run a command stored in a string (or based on the output of another program):
eval 'echo Hello World'
eval $(magic-ssh-commmand-generator)
From man bash
:
eval [arg ...]
The args are read and concatenated together into a single command.
This command is then read and executed by the shell, and its exit status
is returned as the value of eval. If there are no args, or only null
arguments, eval returns 0.
You can use eval
to run a command stored in a string (or based on the output of another program):
eval 'echo Hello World'
eval $(magic-ssh-commmand-generator)
From man bash
:
eval [arg ...]
The args are read and concatenated together into a single command.
This command is then read and executed by the shell, and its exit status
is returned as the value of eval. If there are no args, or only null
arguments, eval returns 0.
answered Dec 19 '18 at 20:00
nohillside
2,292819
2,292819
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.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- 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%2f489996%2fusing-the-output-of-a-command-to-generate-an-ssh-login%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
Can't you just
eval
the string?– nohillside
Dec 19 '18 at 19:52
@nohillside "| eval" leaves me with ssh'ed in with a locked up console
– Peter Turner
Dec 19 '18 at 19:54
eval $string
:-)– nohillside
Dec 19 '18 at 19:55
Or probably rather
eval $(command-which-produces-string)
– nohillside
Dec 19 '18 at 19:56
@nohillside , that'll do ! sweet - thanks. You want to make that an answer or is this too dumb of a question for a person who thinks they "know unix" to ask?
– Peter Turner
Dec 19 '18 at 19:57