How to set up SSH on Free BSD?

Looks for assistance in setting up a Free BSD box to be reachable via SSH and to have SSH load on this box each time it is started.  Thanks.
LVL 1
mmedwidAsked:
Who is Participating?
 
StirchConnect With a Mentor Commented:
May be you should try to add fillowing line to /etc/rc.conf -
sshd_enadle = "YES"
0
 
ahoffmannCommented:
you need to add the /path/to/sshd to the rc startup script, probably /etc/rc.local
Then setup /etc/sshd_config and start sshd.
0
 
yuzhCommented:
Hi mmedwid,

  1. Download a copy of SSH from the following site:
     http://www.openssh.com/
  or somewhere else if you alread know.

  2. Following the instructions (README file etc) install
     it on your system
     (eg, put it under /usr/local)

  3. use a text edtor to edit the ssh configuration files (I assume that you install it under /usr/local)
     /usr/local/etc/ssh_config
     /usr/local/etc/ssh_config
  note: you can use all the default setting first and make
        the change later.

  4. cd to the ssh bin dir, run the following command:
     ./ssh-keygen -t dsa
     Note: this will generates authentication keys
           for your system

  5. Modify the following script (I wrote this one for my  systems) and put it under /etc/rc2.d,

  ====================================================
  #!/sbin/sh
  # This script is for start and stop the OpenSSH daemon -- sshd
 
  #
  # OpenSSH configuration files location: /usr/local/etc
  # OpenSSH key files location: /etc/ssh2
  #
  # Generic script used to start and stop a service

  case "$1" in

   'start')

          # Start the sshd server
        if [ -f /usr/local/sbin/sshd ]; then
                 /usr/local/sbin/sshd &
         fi
         ;;
   'stop')
       pid=`ps -ef | grep sshd | grep -v grep | awk '{print $2} ' `
       if test "$pid" ;  then
        /usr/bin/kill $pid
       else
              echo "No PID file. Process may not be running"
       fi
  ;;
  *)
      echo "Usage: /etc/init.d/sshd { start | stop }"
      ;;
  esac
  exit 0
  #======================================================

  Save it as S91sshd, and set the permission as the followings:
  -rwxr--r--   1 root     sys          818 Nov 21 11:20 S91sshd*

  6. Start the sshd deamon (ssh server):
  /etc/rc2.d/S91sshd start

  That's all you need to do.

  Good luck!
=============
yuzh
 
0
Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
ahoffmannCommented:
pid="`ps -ef|awk '/\/s\shd/{print $2}'`"  # ;-)
0
 
yuzhCommented:
Sorry, I was not thinking, you should put the script in:
/etc/rc.local.

We are talking about free BSD.
0
 
mmedwidAuthor Commented:
Thanks.  I'll try this out tomorrow.  Working from home today.  
0
 
yuzhCommented:
May be you need to read this as well:

http://www.freebsd.org/handbook/openssh.html
0
 
mmedwidAuthor Commented:
Yeah - this is what I found reading through one of the docs.  I like the simple approach.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.