Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

At work we have freeBSD testmachine. And we have a PHP script that uses SSH2 protocol to connect with the freeBSD server. With this script I'm not able to connect to the freeBSD server. I wanted to install it, but I'm not sure where to find the right source to compile.

The connection can be made with a different machine, but isntalling a new distro isn't the solution right now.

I can connect to the server over ssh, but not with the ssh2 protocol in PHP (

share|improve this question
What version of FreeBSD? What's the output of "uname -srm"? How about the version of ssh: "ssh -v"? – Geoff Fritz Dec 2 '09 at 17:27
up vote 5 down vote accepted

FreeBSD has OpenSSH-server installed by default

Enable it with sshd_enable=YES in rc.conf, and run "sh /etc/rc.d/sshd start"

Edit: Make sure "Protocol 2" is enabled in /etc/ssh/sshd_config and reload sshd with "sh /etc/rc.d/sshd reload".

share|improve this answer
I can connect to the server with SSH. That ain't the problem. But not by the SSH2 protocol. this is different from SSH1. – Robert Cabri Dec 2 '09 at 14:41
Please paste the output from "grep 'Protocol' /etc/ssh/sshd_config" – pauska Dec 2 '09 at 14:55
sshd_enable="YES" is allready set – Robert Cabri Dec 2 '09 at 14:56
FreeBSD's SSH server uses tcp_wrappers. Make sure that /etc/hosts.allow allows ssh access from the server running the php/ssh script. – Geoff Fritz Dec 2 '09 at 17:22
I repeat, please post the output from "grep 'Protocol' /etc/ssh/sshd_config" – pauska Dec 2 '09 at 21:25

make sure sshd_enable="YES" is in /etc/rc.conf

/etc/rc.d/sshd keygen

/etc/rc.d/sshd start

SSHv2 is allowed by default, but freebsd also allows sshv1. I set protocol to 2 only, but this should be option for what you're trying to accomplish.

share|improve this answer

Either build it by doing

cd /usr/ports/security/ssh2
make && make install

or install it using

pkg_add -r ssh2

This should do the trick.

Best wishes, Fabian

share|improve this answer
OpenSSH (the ssh server/client included in the base FreeBSD system) supports the SSH2 protocol (and only SSH2) by default since SSH1 has security issues. The installation of the ssh2 port shouldn't be necessary. – Geoff Fritz Dec 2 '09 at 17:19

Open terminal and use bellow commands to install ssh2

cd /usr/ports/security/ssh2 make && make install

or use

pkg install ssh2

this should work properly

share|improve this answer
I don't think this adds anything that Halfdan's answer doesn't - and that has been criticised for being wrong. – MadHatter Feb 24 at 7:42

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.