- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- rc file for ssh
Operating System - HP-UX
1753521
Members
4890
Online
108795
Solutions
Forums
Categories
Company
Local Language
юдл
back
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Forums
Forums
Discussions
юдл
back
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Blogs
Information
Community
Resources
Community Language
Language
Forums
Blogs
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-19-2004 03:00 AM
тАО04-19-2004 03:00 AM
rc file for ssh
I have a script that works fine for ssh but not scp, the who command does not work without a tty.
I would like a sollution that works for both ssh and scp?
file /.ssh/rc
#!/usr/bin/ksh
LOGIN_HOST=$(who -um | awk '{print $NF}')
case $LOGIN_HOST in
'system hostname')
echo "OK"
;;
'system ip')
echo "OK"
;;
*)
KILL_PTS=$(who -um | awk '{print $2}')
LOGOUT=$(ps -ef | grep $KILL_PTS | grep -v grep | grep sshd | awk '{print $2}')
kill -9 $LOGOUT
;;
esac
I would like a sollution that works for both ssh and scp?
file /.ssh/rc
#!/usr/bin/ksh
LOGIN_HOST=$(who -um | awk '{print $NF}')
case $LOGIN_HOST in
'system hostname')
echo "OK"
;;
'system ip')
echo "OK"
;;
*)
KILL_PTS=$(who -um | awk '{print $2}')
LOGOUT=$(ps -ef | grep $KILL_PTS | grep -v grep | grep sshd | awk '{print $2}')
kill -9 $LOGOUT
;;
esac
- Tags:
- ssh
2 REPLIES 2
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-19-2004 03:21 PM
тАО04-19-2004 03:21 PM
Re: rc file for ssh
Hello,
If you want to know if ksh is executed in interactive mode use this test :
if [[ -o interactive ]] ; then
...
else
...
fi
Cheers
Nicolas
If you want to know if ksh is executed in interactive mode use this test :
if [[ -o interactive ]] ; then
...
else
...
fi
Cheers
Nicolas
All different, all Unix
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-19-2004 07:27 PM
тАО04-19-2004 07:27 PM
Re: rc file for ssh
for the information:
This is a script that will let root in for a sincle server. This script will not affect other protocols as telnet :-).
With the script:
#!/usr/bin/ksh
if [[ -o interactive ]]
then
echo "STATEMENT 1"
else
echo "STATEMENT 2"
LOGIN_HOST=$(who -um | awk '{print $NF}')
case $LOGIN_HOST in
'')
echo "OK"
;;
'')
echo "OK"
;;
*)
KILL_PTS=$(who -um | awk '{print $2}')
LOGOUT=$(ps -ef | grep $KILL_PTS | grep -v grep | grep sshd | awk '{print $2}')
kill -9 $LOGOUT
;;
esac
fi
I get the following output on scp:
root@'s password:
STATEMENT 2
$ process not attached to terminal
for ssh i get the following output:
$ ssh -l root
root@'s password:
STATEMENT 2
OK
so the:
if [[ -o interactiv ]]
doesn't work
This is a script that will let root in for a sincle server. This script will not affect other protocols as telnet :-).
With the script:
#!/usr/bin/ksh
if [[ -o interactive ]]
then
echo "STATEMENT 1"
else
echo "STATEMENT 2"
LOGIN_HOST=$(who -um | awk '{print $NF}')
case $LOGIN_HOST in
'
echo "OK"
;;
'
echo "OK"
;;
*)
KILL_PTS=$(who -um | awk '{print $2}')
LOGOUT=$(ps -ef | grep $KILL_PTS | grep -v grep | grep sshd | awk '{print $2}')
kill -9 $LOGOUT
;;
esac
fi
I get the following output on scp:
root@
STATEMENT 2
$ process not attached to terminal
for ssh i get the following output:
$ ssh -l root
root@
STATEMENT 2
OK
so the:
if [[ -o interactiv ]]
doesn't work
The opinions expressed above are the personal opinions of the authors, not of Hewlett Packard Enterprise. By using this site, you accept the Terms of Use and Rules of Participation.
News and Events
Support
© Copyright 2024 Hewlett Packard Enterprise Development LP