Contact SalesSitemapCustomer Login

Warning: mysql_connect() [/function.mysql-connect]: Can't connect to MySQL server on 'coredb-01.spry.com' (13) in [path]/vpslink_template_files/contextual_ads.inc.php on line 56

Go Back   VPSlink Forums > Control Panels > My.VPSLink.com Support

Closed Thread
 
Thread Tools Display Modes
  #1 (permalink)  
Old 09-20-2009, 10:44 PM
Junior Member
 
Join Date: Nov 2008
Posts: 15
Default ssh disconnects immediately upon successful login

The title says it all. I recently put `exec screen -R` in my .bash_profile, and that's the only change I've made. I have disconnected/reconnected several times since then.

Specifically: I get a login prompt, type my username, type my valid password, and see my 'last login' message before the puTTY window closes. If I type the incorrect password I get 'access denied' and get to try again (no disconnect until I login).

OS: Fedora 9 I believe.

Any ideas?
  #2 (permalink)  
Old 09-20-2009, 11:05 PM
Junior Member
 
Join Date: Nov 2008
Posts: 15
Default

Turns out I had SCP access, so I scp'd in and renamed .bash_profile to .bash_profile.ignore and now I can ssh again. Apparently screen wasn't happy with being in .bash_profile... hope this helps someone in the future.
  #3 (permalink)  
Old 09-20-2009, 11:48 PM
Administrator
 
Join Date: Dec 2007
Posts: 1,141
Default

screen's default behavior will kill your present TTY session when run from a .bash_profile or .bashrc script as soon as screen successfully runs.

If you plan to experiment with your login scripts, I would highly recommend adding a sleep 5 call before the experimental commands in your login script (this will give you a chance to break from the script back to the shell if you find that subsequent commands have an undesirable effect).

You will also want to use a comparison to ensure that your screen sessions do not start screen sessions

Code:
if [ $TERM != "screen" ]; then
  echo -n "Ctrl-C now to avoid screen - in 5 secs..." && sleep 1 && echo -n " 4 secs..." && sleep 1 && echo -n " 3 secs..." && sleep 1 && echo -n " 2 secs..." && sleep 1 && echo -n " 1 sec..." && sleep 1 && screen -D -RR
else
  echo "Running in screen session..."
fi

Last edited by DanL@VPSLink; 09-21-2009 at 03:02 PM.
  #4 (permalink)  
Old 09-21-2009, 01:21 AM
Junior Member
 
Join Date: Nov 2008
Posts: 15
Default

Many thanks, Dan, very helpful info.
  #5 (permalink)  
Old 09-21-2009, 01:55 AM
Administrator
 
Join Date: Dec 2007
Posts: 1,141
Default

You are most welcome - here's a more configurable alternative, should you want to experiment:

Code:
# screen autostart
if [ $TERM != "screen" ]; then
  # Configuration
  SCRAUTO_CMD='screen -D -RR'
  SCRAUTO_DELAY=10
  # EOF - Configuration
  SCRAUTO_DISPLAY=$SCRAUTO_DELAY+1
  echo -n "(Ctrl+C to skip) Running "${SCRAUTO_CMD}" in "
  for (( i=0; i<=$SCRAUTO_DELAY; i++ ))
  do
    let SCRAUTO_DISPLAY=SCRAUTO_DISPLAY-1
    echo -n ${SCRAUTO_DISPLAY}"... "
	sleep 1
  done
  ${SCRAUTO_CMD}
else
  echo "Running in screen session..."
fi
  #6 (permalink)  
Old 09-21-2009, 03:05 PM
Administrator
 
Join Date: Dec 2007
Posts: 1,141
Default

... our support manager has informed me that screen -D -R added at the end of your .bash_profile script should accomplish everything the above script does in about 6% of the lines (see man screen for "Author's favorite" for full details).
Closed Thread

Bookmarks

Thread Tools
Display Modes

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 On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off



All times are GMT. The time now is 11:26 AM.


Powered by vBulletin® Version 3.8.5
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.2.0