I have a script which I want to execute on a remote machine using ssh.
I am using ssh boxname -n "script.sh [ARG1]"
Depending upon the parameter passed it picks up the .profile to be sourced. However when I try to print the values of variables defined in that .profile, it doesn't show up.
Need assistance in finding out the solution.
The script is present in the remote box to which I am doing ssh
Thanks in advance.
Last edited by deo_kaustubh; 09-07-2010 at 06:54 AM..
Reason: update to the query
You cannot print environment values if the script and process both reside somewhere else.
You have to edit the remote script. Then save it back onto the site.
Try inserting the env command into the script where it will show what variables have been set in .profile. Save it back onto the remote site as "test.sh", then run it.
There is a workaround if you cannot create a script on the other machine -
If your script fails (returns nonzero) because it does not work correctly then change the && to ||.
Hi,
I am trying to complete my bash script in order to find which SSH servers on LAN are still active with the ssh keys, but i am frozen at this step:
#!/bin/bash
# LAN SSH KEYS DISCOVERY SCRIPT
</etc/passwd \
grep /bin/bash |
cut -d: -f6 |
sudo xargs -i -- sh -c '
&& cat... (11 Replies)
Hi,
I want to validate ssh connection one after one for multiple servers..... password less keys already setup but now i want to validate if ssh is working fine or not...
I have .sh script like below and i have servers.txt contains all the list of servers
#/bin/bash
for host in $(cat... (3 Replies)
I'm trying to setup a link between my home pc (work-machine) and a server at work (tar-machine) that is behind a gateway (hop-machine) and not directly accessible.
my actions:
work-machine$ ssh -L 1234:tar-machine:22 hop-machine
work-machine$ ssh -p 1234 user@127.0.0.1
- shh access on... (1 Reply)
I have write a script which contains
ssh -p 12345 dcplatform@10.125.42.50
ssh 127.0.0.1 -p 5555 "$CMD"
ssh root@$GUEST_IP "$CMD"
before I use public key, it works well, now I want to change to "expect", BUT I don't want to change above code and "parameter position"
I can post a... (1 Reply)
Hi,
I want to use ssh to add a register key on remote ssh server. Since there are space characters in my register key string, it always failed. If there is no space characters in the string, it worked fine. The following is what I have tried. It seems that "ssh" command doesn't care about double... (9 Replies)
I am using Net::SSH::Expect to connect to the device(iLO) with SSH. After the $ssh->login() I'm able to view the prompt, but not able to send any coommands.
With the putty I can connect to the device and execute the commands without any issues.
Here is the sample script
my $ssh =... (0 Replies)