Mailing List Archive

Support open source code!


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: tlug: OpenSSH



Hi,


I have no ideas re: NT because I've never had the (dis?)pleasure of using
NT.

Here's the way it works on my laptop, with the Debian OpenSSH package
installed and the default setup. With apologies to Hikaru Utada, it's
automatic...

The sshd daemon is started by init when I boot.
 
> The instance of ssh-agent seem to be valid only for that xterm. Once the
> xterm is terminated, the ssh-agent is terminated too.
 
I'm not at all an expert in how this works, hopefully someone will set me
straight, but that seems like a good thing to me. When the shell that the
agent was started in is terminated, it goes, too. I don't think I'd want
little ssh-agent processes floating around out there.

The ssh-agent gets started for me automatically when I start an X session.
Basically, as I understand it, my xsession is a child of the ssh-agent
process. When I kill my xsession, the ssh-agent process is terminated, too.
Like this:

<jseebach@example.com: /etc/X11> ps wux | grep ssh-agent
jseebach 30622  0.0  0.6  2252   808  ?  S    17:16   0:00 /usr/bin/ssh-agent sh /home/jseebach/.xsession

Might be easier to see what's happening if you look at the
/etc/X11/Xsession, where this gets set up. I'm going to include the entire
thing here because it's late and I'm too lazy to go through it and cut out
the sections that might be relevant. So, my apologies for the long post
that will result:

-------------------------------
#!/bin/sh
#
# /etc/X11/Xsession
#
# global Xsession file -- used by both xdm and xinit (startx)

# If /etc/environment is present, source it. It's useful to put default
# environment settings in this file, and then source it both here and in
# /etc/profile.
if [ -f /etc/environment ]; then
  . /etc/environment
fi

optionfile=/etc/X11/Xsession.options

sysmodmap=/etc/X11/Xmodmap
usrmodmap=$HOME/.Xmodmap
sysresources=/etc/X11/Xresources
usrresources=$HOME/.Xresources

startup=$HOME/.xsession

startssh=
sshagent=/usr/bin/ssh-agent

if [ -x $sshagent -a -z "$SSH_AUTH_SOCK" ]; then
  startssh=yes
fi

for errfile in "$HOME/.xsession-errors" "${TMPDIR:-/tmp}/xses-$USER" "/tmp/xses-$USER"; do
  if ( cp /dev/null "$errfile" 2> /dev/null ); then
    chmod 600 "$errfile"
    exec > "$errfile" 2>&1
    break
  fi
done

case $# in
  0)
    ;;
  1)
    case "$1" in
      failsafe)
        if grep -qs ^allow-failsafe $optionfile; then
          if [ -x /usr/bin/X11/xterm ]; then
            exec xterm -geometry +1+1
          else
            echo "Xsession: unable to launch failsafe X session: xterm not found."
            exit
          fi
        fi
        ;;
      default)
        ;;
      *)
        program=$(which $1)
        if [ -x $program ]; then
          startup=$program
        else
          echo "Xsession: unable to launch $1 X session: $1 not found."
        fi
        ;;
    esac
    ;;
  *)
    echo "Xsession: unsupported number of arguments ($#)."
    ;;
esac

if [ -d $sysresources ]; then
  xrdb -load /dev/null # work around wdm brain damage
  if [ "$(echo $sysresources/*)" != "$sysresources/*" ]; then
    for resourcefile in $(ls $sysresources/* 2> /dev/null | egrep '^[-/_[:alnum:]]*$'); do
      xrdb -merge $resourcefile
    done
  fi
fi

if [ -x /usr/bin/X11/xmodmap ]; then
  if [ -f $sysmodmap ]; then
    xmodmap $sysmodmap
  fi
fi

if grep -qs ^allow-user-resources $optionfile; then
  if [ -f $usrresources ]; then
    xrdb -merge $usrresources
  fi
fi

if [ -x /usr/bin/X11/xmodmap ]; then
  if grep -qs ^allow-user-modmap $optionfile; then
    if [ -f $usrmodmap ]; then
      xmodmap $usrmodmap
    fi
  fi
fi

if [ -e $startup ] && grep -qs ^allow-user-xsession $optionfile; then
  if [ -x $startup ]; then
    realstartup=$startup
  else
    realstartup="sh $startup"
  fi
elif [ -e /etc/X11/window-managers ]; then
  for i in `sed 's/#.*//' /etc/X11/window-managers`; do
    if [ -x $i ]; then
      realstartup=$i
      break
    fi
  done
fi

if [ -z "$realstartup" ]; then
  if [ -x /usr/bin/X11/twm ]; then
    realstartup=twm
  elif [ -x /usr/bin/X11/xterm ]; then
    realstartup=xterm
  else
    echo -n "Xsession: unable to start X session: "
    if grep -qs ^allow-user-xsession $optionfile; then
      echo -n "no $startup found, "
    fi
    echo "no registered window managers, twm not found, and xterm not found."
  fi
fi

if [ "$startssh" ]; then
  exec $sshagent $realstartup
else
  exec $realstartup
fi
-------------------------------

Hope this helps.

John
-- 
jseebach@example.com
--
      Grandfather fingers
a bough of whitepink rice cakes
     on a northbound train
--------------------------------------------------------------------
Next Nomikai Meeting: February 18 (Fri) 19:00 Tengu TokyoEkiMae
Next Technical Meeting:  March 11 (Sat) 13:00 Temple University Japan
* Topic: TBD
--------------------------------------------------------------------
more info: http://www.tlug.gr.jp        Sponsor: Global Online Japan

Home | Main Index | Thread Index

Home Page Mailing List Linux and Japan TLUG Members Links