Re: [gentoo-user] [OT] Passing env variable to ssh?
On Mon, 13 Mar 2006, Mariusz P?kala wrote: Stdin? echo "$myvar" | ssh [EMAIL PROTECTED] ./bin/mycommand ? Yup. Thanks! -- Jorge Almeida -- gentoo-user@gentoo.org mailing list
Re: [gentoo-user] [OT] Passing env variable to ssh?
On Mon, 13 Mar 2006, Hans-Werner Hilse wrote: Hi, On Mon, 13 Mar 2006 20:14:33 + (WET) Jorge Almeida <[EMAIL PROTECTED]> wrote: I want something like this: myvar="whatever" ssh [EMAIL PROTECTED] ./bin/mycommand $myvar [...] This does not work, because remotebox doesn't know about $myvar. Of course, if I could pass a variable to remotebox, the line might be just command="~/bin/mycommand" and the ssh command would be myvar="whatever" ssh [EMAIL PROTECTED] ./bin/mycommand (the program itself would use the value of $myvar) Hm, I think you're making it unnecessary complex. What's wrong with just piping it on stdin? I.e.: Indeed. The problem was me not understanding the relation of stdin with ssh when in non interactive mode... local$ echo "whatever" | ssh [EMAIL PROTECTED] ./bin/mycommand and in ./bin/mycommand: --- #!/bin/sh read myvar # do whatever --- I tested and it works great. It seems I have a lot to learn although I use ssh daily with no problems. Or do you in fact use a pseudo tty on remote side for interactive mode (which would make this a little more difficult)? If you want to keep your way of doing it, I just have a few hints, but didn't test anything, just looked them up out of curiosity: - read "man sshd_config", item AcceptEnv, PermitUserEnvironment I knew about PermitUserEnvironment and SendEnv, but somehow I missed AcceptEnv... Anyway, AcceptEnv seems to be global, wich is not what I want. - read "man sshd", section LOGIN PROCESS You lost me here! I can't see relevancy---PermitUserEnvironment allows to use variables but not to set them from local. Anyway, stdin is the answer. Thank you. -hwh -- Jorge Almeida -- gentoo-user@gentoo.org mailing list
Re: [gentoo-user] [OT] Passing env variable to ssh?
Hi, On Mon, 13 Mar 2006 20:14:33 + (WET) Jorge Almeida <[EMAIL PROTECTED]> wrote: > I want something like this: > myvar="whatever" ssh [EMAIL PROTECTED] ./bin/mycommand $myvar > [...] > This does not work, because remotebox doesn't know about $myvar. Of > course, if I could pass a variable to remotebox, the line might be just > command="~/bin/mycommand" > and the ssh command would be > myvar="whatever" ssh [EMAIL PROTECTED] ./bin/mycommand > (the program itself would use the value of $myvar) Hm, I think you're making it unnecessary complex. What's wrong with just piping it on stdin? I.e.: local$ echo "whatever" | ssh [EMAIL PROTECTED] ./bin/mycommand and in ./bin/mycommand: --- #!/bin/sh read myvar # do whatever --- Or do you in fact use a pseudo tty on remote side for interactive mode (which would make this a little more difficult)? If you want to keep your way of doing it, I just have a few hints, but didn't test anything, just looked them up out of curiosity: - read "man sshd_config", item AcceptEnv, PermitUserEnvironment - read "man sshd", section LOGIN PROCESS -hwh -- gentoo-user@gentoo.org mailing list
Re: [gentoo-user] [OT] Passing env variable to ssh?
On 2006-03-13 20:14:33 + (Mon, Mar), Jorge Almeida wrote: > Anyone knows a way to pass an environment variable to a openssh command? > I doubt there is a way, but who knows... > I want something like this: > myvar="whatever" ssh [EMAIL PROTECTED] ./bin/mycommand $myvar > This would execute a command with argument "whatever". The problem is that I > want to authenticate via a cryptographic key allowing only this command, > i.e., the file ~/.ssh/authorized_keys of myuser at remotebox has a line > command="~/bin/mycommand $myvar" > This does not work, because remotebox doesn't know about $myvar. Of > course, if I could pass a variable to remotebox, the line might be just > command="~/bin/mycommand" > and the ssh command would be > myvar="whatever" ssh [EMAIL PROTECTED] ./bin/mycommand > (the program itself would use the value of $myvar) > > Any idea? Stdin? echo "$myvar" | ssh [EMAIL PROTECTED] ./bin/mycommand ? -- No virus found in this outgoing message. Checked by "grep -i virus $MESSAGE" Trust me. pgptlJO7V5PGW.pgp Description: PGP signature
[gentoo-user] [OT] Passing env variable to ssh?
Anyone knows a way to pass an environment variable to a openssh command? I doubt there is a way, but who knows... I want something like this: myvar="whatever" ssh [EMAIL PROTECTED] ./bin/mycommand $myvar This would execute a command with argument "whatever". The problem is that I want to authenticate via a cryptographic key allowing only this command, i.e., the file ~/.ssh/authorized_keys of myuser at remotebox has a line command="~/bin/mycommand $myvar" This does not work, because remotebox doesn't know about $myvar. Of course, if I could pass a variable to remotebox, the line might be just command="~/bin/mycommand" and the ssh command would be myvar="whatever" ssh [EMAIL PROTECTED] ./bin/mycommand (the program itself would use the value of $myvar) Any idea? -- Jorge Almeida -- gentoo-user@gentoo.org mailing list