Ethical Hacking

Learn to find vulnerabilities before the bad guys do! Gain real world hands on hacking experience in our state of the art hacking lab. Course designed and taught by expert instructors with years of penetration testing experience. 12 student maximum in every class. Certification attempt included in every package.
Computer Forensics Training at InfoSec Institute

Gain the in-demand skills of a certified computer examiner, learn to recover trace data left behind by fraud, theft, and cybercrime perpetrators. Discover the source of computer crime and abuse at your organization so that it never happens again. All of our class sizes are guaranteed to be 12 students or less to facilitate one-on-one interaction with one of our expert instructors.




Network Security Secure-Shell
[Top] [All Lists]

Re: How to export variables on remote machine through ssh.

Subject: Re: How to export variables on remote machine through ssh.
Date: Tue, 27 Nov 2007 22:37:10 +0100 (CET)
On Tue, 27 Nov 2007, gajendrasharma1 wrote:

a=10
ssh -l $user $host "export myVar=$a; cd $myDir; ./myScript.sh"

this doesn't work, as probably the ssh shell might not understand the export
command.

        hi, this should definitely work since ssh knows nothing about that, 
it's just about the remote shell that is run with -c "<the code>"; if you 
expand the variable locally (which you did in the example above) it's ok.

        however, you can also use SendEnv/AcceptEnv with OpenSSH.

        this just works for me:

$ cat test.sh 
#!/bin/sh

echo $a

$ ssh localhost "export a=xx; ./test.sh"
xx

        the same with 'ssh localhost "a=xx ./test.sh"'

        J.

-- 
Jan Pechanec

<Prev in Thread] Current Thread [Next in Thread>