Sponsored Content
Top Forums Shell Programming and Scripting Script as login shell (passing args to login shell) Post 302895343 by maverick72 on Monday 31st of March 2014 10:14:03 AM
Old 03-31-2014
Script as login shell (passing args to login shell)

Hello all,

for security reasons my compagny imposes that my script be launch remotly via ssh under the users login shell.

So serverA launches the ssh command to serverB which has a local user with my script as a login shell.

Local script works like a charm on his own.

Code:
serverB$ grep user1 /etc/passwd
user1:x:921:921::/home/user1:/home/user1/insert_host_ip_named.bash

serverA$ ssh -t user1@serverB

Everything works fine until i bring up arguments

For testing purpose i've replaced the 3 first lines of my script with:
Code:
echo $#
echo $*
sleep 3
exit

and i get this:
Code:
 ssh user1@serverB -- "-i 275.30.44.55 -n WYWYOU"
2
-c -i 275.30.44.55 -n WYWYOU

Which is not good cause the script needs at least 4 args to run:
Code:
# Check number of arguments
case $# in
         4|5) ;;
         *) usage; exit 1 ;;
esac

Any way too make him pass more than 2 arguments?... and he's probably counting the -c as one.
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

remote login via shell script

is it possible for me to have a shell script log me in to a telnet session? i have in mind something along the lines of % telnet host < script, where the first two lines of script will be username and pass followed by a list of commands to execute on the remote host. this doesn t work as... (4 Replies)
Discussion started by: lethe
4 Replies

2. Shell Programming and Scripting

remote-login via Shell-Script

Hello all, I would like to login from one unix-system with a (tcsh)-script to an other unix-system.The login-procedure and the transmission of username, resp. password runs via ssh. The problem is after logging onto the remote server once "Enter" has to be pressed, before one gets to the... (1 Reply)
Discussion started by: Juergen Paepke
1 Replies

3. HP-UX

cannot login after changing login shell

Hello Everyone, I am a newbie in unix. I was practicing shell scripts on hp unix machine. I changed my current login shell (Korn) to Bourne shell giving the following command. $ chsh username /usr/bash I am using secure shell client for accessing the hp ux server. After which i... (4 Replies)
Discussion started by: hardesh
4 Replies

4. Shell Programming and Scripting

login from a shell script?????

Any help on this ..... its a bit urgent !!!! Hi Can anybody provide info about the following??? i want to issue su (switch user) command from within a shell script how to take the password without user intervention from the shell script only???? i.e using apssword which is already... (2 Replies)
Discussion started by: skyineyes
2 Replies

5. Shell Programming and Scripting

Login with Shell Script.

Dear All, I need to create a shell script which will login to a unix system with user root. I also need to supply the password for root through script only instead of entering it manually. After i am logged in to the system i need to excute all the necessary commands. so far i have done... (7 Replies)
Discussion started by: Siddheshk
7 Replies

6. Shell Programming and Scripting

SSH - Passing Unix login passwords through shell scripts

Hi All , I need to call a script runscript_B.sh on server A, the runscript_B.sh script locating in server B. The runscript_B.sh in calls another script runscript_A on server A itself. it seend, i need to be connect from Server A to Server B using ssh. I have tryed like this in... (3 Replies)
Discussion started by: koti_rama
3 Replies

7. Shell Programming and Scripting

Help with Unix bash shell script login

Hi, I am a complete Unix novice and need some help with creating a login shell script. I have created a file with user details i.e. PIN, name etc and require help in recalling the specified details from the file and being prompted for a password on login. Any help would be very much appreciated.... (0 Replies)
Discussion started by: tdsrogers
0 Replies

8. Shell Programming and Scripting

passing login details to htaccess login prompt

Hi, How i can pass the login details to the URL which is password protected with the htaccess using command line or script (perl,or shell,or php). Any help or hint appreciated. Thanks, SJ (4 Replies)
Discussion started by: SilvesterJ
4 Replies

9. Shell Programming and Scripting

How to login as a different user inside a shell script?

hi, i want to login as a different user inside a shell script and then call another shell script from that script. how to do that? original script : script_A.sh so when the script_A.sh is called , i want to login as a different user and then call another shell script(script_B.sh) from... (3 Replies)
Discussion started by: Little
3 Replies

10. Shell Programming and Scripting

Shell script for login user and email

Guys please help me I have a linux class and I want to write a shell script who shows which user loged in and show the process that are active in his/her shell in another text file and email that file to root just when the user loged out Thanks every bod (1 Reply)
Discussion started by: hamedk1122
1 Replies
CHSH(1) 							   User Commands							   CHSH(1)

NAME
chsh - change login shell SYNOPSIS
chsh [options] [LOGIN] DESCRIPTION
The chsh command changes the user login shell. This determines the name of the user's initial login command. A normal user may only change the login shell for her own account; the superuser may change the login shell for any account. OPTIONS
The options which apply to the chsh command are: -h, --help Display help message and exit. -R, --root CHROOT_DIR Apply changes in the CHROOT_DIR directory and use the configuration files from the CHROOT_DIR directory. -s, --shell SHELL The name of the user's new login shell. Setting this field to blank causes the system to select the default login shell. If the -s option is not selected, chsh operates in an interactive fashion, prompting the user with the current login shell. Enter the new value to change the shell, or leave the line blank to use the current one. The current shell is displayed between a pair of [ ] marks. NOTE
The only restriction placed on the login shell is that the command name must be listed in /etc/shells, unless the invoker is the superuser, and then any value may be added. An account with a restricted login shell may not change her login shell. For this reason, placing /bin/rsh in /etc/shells is discouraged since accidentally changing to a restricted shell would prevent the user from ever changing her login shell back to its original value. FILES
/etc/passwd User account information. /etc/shells List of valid login shells. /etc/login.defs Shadow password suite configuration. SEE ALSO
chfn(1), login.defs(5), passwd(5). shadow-utils 4.1.5.1 05/25/2012 CHSH(1)
All times are GMT -4. The time now is 07:18 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy