Ssh – So Close: How to get this SSH login working (.bashrc)

bashrcssh

Objective: SSH login ( + eliminate warning message) / run 2 commands / stay logged in:

EDIT: Oops, I made a mistake (see below):

This code does ~95% of what I wanted to do

# .bashrc
# Run two commands and stay logged in to new server.
alias gr='ssh -t -p 5xx4x root@9x.1xx.51.00 2> /dev/null "cd /var; ls; /bin/bash -i"'

Now, after successful login / verify user logged in =

root pts/0 2011-01-30 22:09

Try to 'logout' =

bash: logout: not login shell: use
`exit'

I seem to have full root access w/o being logged into the shell? (The " /bin/bash -i " was added to 'Stay logged in' but doesn't work quite as expected)
FYI: The question is "How to get this SSH login working" & it is mostly solved, sorry I made a mess…

..

.

Original Question Here:

# .bashrc
# Run two commands and stay logged in to new server.
alias gr='ssh -t -p 5xx4x root@9x.1xx.51.00 "cd /var; ls; /bin/bash -i"'

# (hack) Hide "map back to the address - POSSIBLE BREAK-IN ATTEMPT!"  message.
alias gr='ssh -p 5xx4x root@9x.1xx.51.00 2> /dev/null'

Both examples 'work' as shown; When I try to add the ' 2> /dev/null ' to the first example, then the whole thing breaks.

  • I'm out of time trying to solve the
    warning message other ways, so is it
    possible
    to combine both examples to
    make example #1 work w/o the warning
    message?

Thank you.

ps. If you also know a proper way to kill the login warning message, please do tell (the 'standard' "edit host file" advice isn't working for me)

Best Answer

You're getting the bash: logout: not login shell: use 'exit' message because you started an interactive non-login shell. Try bash -l or bash -il instead.