LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Security
User Name
Password
Linux - Security This forum is for all security related questions.
Questions, tips, system compromises, firewalls, etc. are all included here.

Notices


Reply
  Search this Thread
Old 03-02-2011, 01:17 PM   #1
gnuweenie
Member
 
Registered: Oct 2010
Posts: 35

Rep: Reputation: Disabled
custom login script for *shared account* (using SSH)


There is a shared account (not by choice, and not my choice). I ssh into it, along with many other users. Some users share the password, others use the public key method (each user has their own pair of keys).

I have a number of shell preferences that I would not want to affect other users. So changing .bashrc, .profile, .kshrc, etc types of scripts in the shared account is not practical, because changing them would affect everyone. What would be a practical way to have a script execute automatically, only when logging in by way of my private (id_rsa) key? Could I perhaps change the .profile in a way that it runs some commands only if my public key was used to authenticate the login?

I've considered this:

ssh sharedUser@host 'bash -s' < my_local_script.sh

but it simply terminates when done. I want it to hand the shell over to me.

Also, when many users are logged in, the "w" command shows several users with the same shared username. Is there anything I can do to make my own session distinct? E.g. instead of showing username "sharedUser", I want it to show "gnuweenie via sharedUser", or something.

Last edited by gnuweenie; 03-03-2011 at 02:15 PM. Reason: solved
 
Old 03-02-2011, 01:34 PM   #2
macemoneta
Senior Member
 
Registered: Jan 2005
Location: Manalapan, NJ
Distribution: Fedora x86 and x86_64, Debian PPC and ARM, Android
Posts: 4,593
Blog Entries: 2

Rep: Reputation: 344Reputation: 344Reputation: 344Reputation: 344
Just make 'bash' the last command you execute. For example:

Code:
ssh remotesystem 'ls;bash'
To make the session distinct, add a comment:

Code:
ssh remotesystem 'ls;bash # gnuweenie via sharedUser'
That comment will show up in a 'ps -Afl'.

Last edited by macemoneta; 03-02-2011 at 01:37 PM.
 
1 members found this post helpful.
Old 03-03-2011, 05:03 AM   #3
Reuti
Senior Member
 
Registered: Dec 2004
Location: Marburg, Germany
Distribution: openSUSE 15.2
Posts: 1,339

Rep: Reputation: 260Reputation: 260Reputation: 260
You could also setup a generic ~/.profile or alike and inside you have cases depending on $SSH_CLIENT (the address of origin), or a custom set variable which you export to the SSH login by -oSendEnv=foobar or alike (when it's configured in the server).

Last edited by Reuti; 03-03-2011 at 05:04 AM. Reason: Formatting
 
1 members found this post helpful.
Old 03-03-2011, 02:08 PM   #4
gnuweenie
Member
 
Registered: Oct 2010
Posts: 35

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by macemoneta View Post
Just make 'bash' the last command you execute. For example:

Code:
ssh remotesystem 'ls;bash'
That doesn't work for me. I tried it in a few cases, and the session simply runs all the commands before the bash and terminates.

Quote:
Originally Posted by Reuti View Post
You could also setup a generic ~/.profile or alike and inside you have cases depending on $SSH_CLIENT (the address of origin), or a custom set variable which you export to the SSH login by -oSendEnv=foobar or alike (when it's configured in the server).
Thanks!
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
cannot login via ssh on a single, non root account - telnet ok paziulek Red Hat 18 06-19-2013 03:28 AM
Custom Login Script Ubuntu 10.10 metallica1973 Ubuntu 2 10-27-2010 03:05 PM
Shared Key ssh login only pccdrussell Linux - General 2 10-19-2007 06:20 PM
Custom ssh login Braynid Linux - Newbie 3 05-27-2006 03:59 PM
can't login to a Slack machine using a NIS account through ssh nIMBVS Slackware 2 07-15-2004 02:15 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Security

All times are GMT -5. The time now is 02:33 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration