Computing.Net > Forums > Solaris > Need help with a simple script

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Need help with a simple script

Reply to Message Icon

Name: Mark M
Date: October 26, 2002 at 02:07:35 Pacific
OS: 5.7
CPU/Ram: Ultra10
Comment:

Hey all.

I'm working on limiting telnet access to one user on my system (with a restricted shell) by way of inserting a simple test condition in the .profile of all user directories.

However, I'm having real trouble getting this script changed over to a format that the .cshrc or .login can use. There are a few accounts that use csh you see (including me) so this won't work unless I can somehow get the syntax changed into a format that it'll understand.

The part I've added to .profile files for ksh users is:

IS_SSH="`echo $SSH_TTY`"
if [ -z "$IS_SSH" ] ; then
echo "WARNING: User not on SSH TERMINAL!"
exit
fi

This basically checks to see if the user is connected via ssh (As SSH_TTY will be set to the term name), and if they aren't (ie: SSH_TTY is empty), the user gets kicked off.

Could come kind soul help me out on how to get this working with the .cshrc too? It doesn't seem to like multiple if statements so I'm confused :S

Many thanks for any help.



Sponsored Link
Ads by Google

Response Number 1
Name: Mark M
Date: October 26, 2002 at 02:22:23 Pacific
Reply:

Also... I should say, I think I could figure this out for myself if someone could tell me how to avoid csh throwing a hissy fit when a variable is not defined previously. The whole "SSH_TTY: Undefined variable" Thing is getting in the way somewhat.

Even trying to output to a file or /dev/null doesn't help :(

Again, thanks in advance.



0

Response Number 2
Name: Mark M
Date: October 26, 2002 at 02:43:39 Pacific
Reply:

Doh, no matter, I figured out I had to do this:

if ($?SSH_TTY) then
echo "You're on SSH"
else
echo "You're not on SSH"
endif

basically, csh is a real pain in the arse to script with as it parses and evaluates the whole line, hence will abort on a variable that isn't set... grrr..

Just to document this for anyone else that wants to do it, just use that script at the top for ksh and bourne shell users, and place the small script above these 2 paragraphs at the start of the .login of a csh user. You can remove/edit as appropriate to control which users can use ssh or telnet. :)

I'll test for any exploits later, but I think it should be pretty safe seeing as they are run in the actual login scripts.


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Solaris Forum Home


Sponsored links

Ads by Google


Results for: Need help with a simple script

I need help with tar and ftp www.computing.net/answers/solaris/i-need-help-with-tar-and-ftp/3846.html

Need help with a script www.computing.net/answers/solaris/need-help-with-a-script/4092.html

help with cron www.computing.net/answers/solaris/help-with-cron/3849.html