Sponsored Content
Operating Systems Solaris Passing SSH Command Parameters Post 302109209 by blowtorch on Monday 5th of March 2007 12:41:54 AM
Old 03-05-2007
PabloCruise77, when connecting with ssh, if you run any commands like this:
Code:
ssh abc@systemxyz "ls -l"

and environment variable called SSH_ORIGINAL_COMMAND is set to whatever parameters you pass in to ssh.

This is an excerpt of an authorized_keys2 file for a user test:
Code:
command="/tmp/test.sh $SSH_ORIGINAL_COMMAND" ssh-dss AAAAB3NzaC1kc3MAAACBAOpMZlRTUFSmgTscvAmqsOwLel2GGHhwTzXvGou6Ta38ZyS32rr
4ITr3ypiIaIbKDPD2c7p5G8t45ctpLvqRCqTUejtPryXgPrKcJuUzS7LG3sbxdahCKMQk/SGgSEdHXd11dQI/O1LwW3FZ25yQsmR9jqNM+wb8b0dM4upbxMxxAAA
AFQCl1eK8NrdbUhStz8WDd1Jc5sF/PwAAAIEAmJlpIcMnHpwBRSKNUto6GfxbLS17l73SDHB8rAP+meYPYfWOaPAsmkQc4UUIdkQJfOzSStgXKsyDH7ybaOWeDcE
Ffw7kroJbu3wXAOl+JPon5C6aXkvGBR3Y7qsBEMXlW57kraot4Rya/RUblh5xjYbYEDcJsPafABUKpRjCbYsAAACBAN1gXh2OHEwOV7+KnHo5fubclort79wAldw
OZ2A+v86hRcEgGb3Bl1qZRVuKvfrgR/OPvxoAeKmMjgrCDld0MgkC3ZdWOhuZhuCzBZRkZTCKnQF4k54r6sc6pWxS/NBBsyvzPmntcakaOb9cLrLf1JnXk3k4xiO
8E037y+OJ3WAX samba@abcxyz

The /tmp/test.sh file is like this:
Code:
#!/usr/bin/ksh

echo "this is a test"
echo $SSH_ORIGINAL_COMMAND
echo $@

As user samba, if I run
Code:
ssh test@abcxyz "hello there"

, I get this:
Code:
$ ssh test@ssunsp3 "hello there"
this is a test
hello there
hello there

So you can just edit the authorized_keys2 file and send the contents of the $SSH_ORIGINAL_COMMAND variable as parameters to the script that you are running.
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

passing parameters to sleep command

Hi, Can any one help me with an example how to use Sleep command with parameters thanx, (1 Reply)
Discussion started by: nagaraju_svs
1 Replies

2. Shell Programming and Scripting

passing command line parameters to functions - sh

All, I have a sh script of the following tune: function a () { #functionality.. } function b () { #functionnlity.. } function check () { # this function checks for env and if all fine call build } function usage () { #sh usage details } function build () { #calls either a or b or... (5 Replies)
Discussion started by: vino
5 Replies

3. Shell Programming and Scripting

passing more than 9 parameters

hi, i am passing around 14 parameters for a script a=$1 b=$2 c=$3 d=$4 e=$5 f=$6 g=$7 h=$8 i=\"${9}\" shift j=\"${1}\" still for j it is displaying the 1st parameter value..how to make it take the 10th parameter (2 Replies)
Discussion started by: dnat
2 Replies

4. AIX

Passing a command over SSH

I'm trying to run a command over ssh to AIX 5.2, something like: ssh machine ls but it just hangs. I can ssh into the machine and run a command, but can't pass it like above. Is there a security setting that disables this by default? If so, how do I change it? Thanks! (8 Replies)
Discussion started by: hansnueski
8 Replies

5. Shell Programming and Scripting

Passing SSH Command Parameters

Hi, I wan to pass arguments to remote script in Unix . For that I'm using ssh PFB the code I'm using: ssh -t -l osdac 10.81.33.51 "cd /appl/OSD/LOGS/flstr010/test.sh "$1" "$2"" Problem is I'm not able to pass second argument . Can anyone plz help me in resolving this. (5 Replies)
Discussion started by: suchitasaner27
5 Replies

6. Shell Programming and Scripting

Passing parameters to Shell script for GREP command

I am using grep to capture date from a file . Since i need to use the shell script for different dates ,is it possible to pass the date parameter to the shell script the Script is as below grep -E "08 Aug 2008|2008-08-08"* somefile.txt>test.txt The above script file greps the... (1 Reply)
Discussion started by: sud.tech
1 Replies

7. Shell Programming and Scripting

passing arguments in remote ssh command?

i have a bash script on serverA, when i run the script on the server, it runs fine. the way to run the script is like this ./script "option1" Now i am trying to call it from local laptop using ssh command, my command is as the following ssh serverA ~/script "option1" and i got error... (7 Replies)
Discussion started by: fedora
7 Replies

8. Shell Programming and Scripting

Passing 2+ parameters to one command

I have a script that uses more than one parameter. It looks like this: for i in `cat /tmp/listofpolicies`; do for x in $(cat /tmp/lst |sed 's/^/\/usr\/openv\/netbackup\/db\/class\//g'); do /usr/openv/netbackup/bin/admincmd/bpplinclude $i -delete -f $x;done;done The problem is that the... (3 Replies)
Discussion started by: newbie2010
3 Replies

9. Shell Programming and Scripting

Passing password with SSH command

Hi Experts, I have specific requirement where I want to pass the password with the ssh username@hostname command . I dont want to use RSA public and private keys also. Because that will be on production server and no one wants to give access like that. Second thing it is production... (14 Replies)
Discussion started by: sharsour
14 Replies

10. Shell Programming and Scripting

Passing command line parameters into script

Not a good post. (1 Reply)
Discussion started by: bash_in_my_head
1 Replies
SSH-KEYSIGN(8)						    BSD System Manager's Manual 					    SSH-KEYSIGN(8)

NAME
ssh-keysign -- ssh helper program for host-based authentication SYNOPSIS
ssh-keysign DESCRIPTION
ssh-keysign is used by ssh(1) to access the local host keys and generate the digital signature required during host-based authentication with SSH protocol version 2. ssh-keysign is disabled by default and can only be enabled in the global client configuration file /etc/ssh/ssh_config by setting EnableSSHKeysign to ``yes''. ssh-keysign is not intended to be invoked by the user, but from ssh(1). See ssh(1) and sshd(8) for more information about host-based authen- tication. FILES
/etc/ssh/ssh_config Controls whether ssh-keysign is enabled. /etc/ssh/ssh_host_dsa_key /etc/ssh/ssh_host_ecdsa_key /etc/ssh/ssh_host_ed25519_key /etc/ssh/ssh_host_rsa_key These files contain the private parts of the host keys used to generate the digital signature. They should be owned by root, read- able only by root, and not accessible to others. Since they are readable only by root, ssh-keysign must be set-uid root if host- based authentication is used. /etc/ssh/ssh_host_dsa_key-cert.pub /etc/ssh/ssh_host_ecdsa_key-cert.pub /etc/ssh/ssh_host_ed25519_key-cert.pub /etc/ssh/ssh_host_rsa_key-cert.pub If these files exist they are assumed to contain public certificate information corresponding with the private keys above. SEE ALSO
ssh(1), ssh-keygen(1), ssh_config(5), sshd(8) HISTORY
ssh-keysign first appeared in OpenBSD 3.2. AUTHORS
Markus Friedl <markus@openbsd.org> BSD
December 7, 2013 BSD
All times are GMT -4. The time now is 04:05 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy