Sunday, November 14, 2010

Setting Up a Bare CentOS server with Ngnix/PHP/MySQL (part 3)

In this post I show how to configure SSH

Remember the last step in part 1?

I assigned an IP address to the virtual adapter so that I can connect via SSH to my virtual box.

Of course it can be any address you wish but it’s best to just use which are the private addresses.

I will be using also a little application that will give me the option to start the VirtualBox in headless mode because, I do not need the window running while I am using SSH.

Also to SSH  I will be using PUTTY (see bottom page for homepage)


The IP address of eth1 will be in my case

eht0 will just have an ip chosen automatically

To add/modify an entry you may need to edit the files in 


there you will have several files including ifcfg-eth0 or ifcfg-eth1. You should have both though if you followed through part 1.

Here are my settings for eth1



The SSH configuration file is located:


just use your normal editor (nano or vi)

Things that should be changed:

Port: SSH uses port 22. I never use port 22 instead I try to use ports higher then 49152 or dynamic ports / private ports these are called.

Here are some settings which I change

Port 50000 listening port for sshd
Protocol 2 See here a list of 2 vs 1
LoginGraceTime 30 How much time shall pass before authentication (default 2m)
PermitRootLogin no Normally not needed since you can just su the commands. I commented out this. In a production environment though you should not do this.
PermitEmptyPasswords no I don’t need to explain this, no ? Smile
MaxStartups 4:50:10 Limit the maximum number of unauthenticated connections that the ssh server will handle at the same time.
The MaxStartups option is in the format start:rate:full. sshd will begin to refuse connections randomly at rate/100 (ie. 50% here) once there are more than start connections.
This refusal probability increases linearly until full number of connections is reached, whereby all connections are refused until some open connections clear up (time out or finish).

More on SSH and configuring here.

Next do a reload. If you do a restart and your are already connected via ssh then that connection will close.

sudo /sbin/service sshd reload

Now fire up PUTTY


Enter the IP address of ethX port # and select SSH then click Open.

That’s it.

FreeBSD Note

# ee /etc/rc.conf
add the command below into the file in order for it to be permanent

ifconfig_em0="inet netmask"

or more concrete but not needed in the case of virtualbox > ssh
ifconfig_em0="inet netmask media 100baseT/UTP mediaopt full-duplex"  

next restart networking
# /etc/rc.d/netif restart    



PUTTY Download Page

No comments:

Post a Comment