Results 1 to 6 of 6

Thread: execute post ssh login script

Hybrid View

  1. #1
    Join Date
    Jul 2007
    Beans
    29

    execute post ssh login script

    hellou, i searched google almost 2 hours, but was not able to find a solution for this.
    i need to run exact script for each user who will connect to server via ssh. problem is, it can not be in .basrc (for bash for example). Reason is simple: it can be killed/changed... bud the script should be "hidden" and not visible to logged user.
    So how would I do that? Thanks and am very curious.

  2. #2
    Join Date
    Aug 2005
    Location
    Fargo, ND, USA
    Beans
    1,499
    Distro
    Kubuntu 10.04 Lucid Lynx

    Re: execute post ssh login script

    Run it from /etc/profile.

    Read the INVOCATION section of the bash man page. The shell you get from ssh is a login shell.
    Last edited by jpkotta; June 28th, 2008 at 11:29 PM.
    Help yourself: Search the community docs or try other resources.
    Quote Originally Posted by Henry Spencer
    Those who do not understand Unix are condemned to reinvent it, poorly.
    Let science use your computer when you aren't: Folding@Home.

  3. #3
    Join Date
    Jul 2007
    Beans
    29

    Re: execute post ssh login script

    Quote Originally Posted by jpkotta View Post
    Run it from /etc/profile.

    Read the INVOCATION section of the bash man page. The shell you get from ssh is a login shell.
    Thanks for help, but this almost I was searching for. In your man page, there was options --noprofile (calling directly for shell - I think this is feasible). So I can not use this for security reason, am I right? I thought that when using sftp I am also lost, but I find out, that /etc/bash.bashrc do the trick (althought it will run my secret script for all my console - neinnnn)
    can be --noprofile option called directly with ssh command?
    Last edited by cccccccc; June 29th, 2008 at 12:07 AM.

  4. #4
    Join Date
    Apr 2008
    Location
    UK
    Beans
    1,098

    Re: execute post ssh login script

    Quote Originally Posted by cccccccc View Post
    hellou, i searched google almost 2 hours, but was not able to find a solution for this.
    i need to run exact script for each user who will connect to server via ssh. problem is, it can not be in .basrc (for bash for example). Reason is simple: it can be killed/changed... bud the script should be "hidden" and not visible to logged user.
    So how would I do that? Thanks and am very curious.
    Install sec. Visit the author's website and read the documentation there. Set up sec to monitor /var/log/auth.log and run your script.
    Brian.

  5. #5
    Join Date
    Sep 2006
    Beans
    2,914

    Re: execute post ssh login script

    check the man page of sshd. you can use /.ssh/rc or using the example described under AUTHORIZED_KEYS FILE FORMAT in the man page.

  6. #6
    Join Date
    Jul 2007
    Beans
    29

    Re: execute post ssh login script

    Quote Originally Posted by ghostdog74 View Post
    check the man page of sshd. you can use /.ssh/rc or using the example described under AUTHORIZED_KEYS FILE FORMAT in the man page.
    thanks all. yes I found ssh/rc too, it doesn't cover sftp connections, very sad. but I will have a look at your second advice.
    still, can anybody answer my question, if it is possible to make command like: ssh user@server.com /bin/bash --noprofile --norc? I saw it somewhere, but it doesn't work for me. if this doesn't work, I could use /etc/bash.bashrc for certain user with if... condition (the monitored one)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •