Showing posts with label FreeBSD. Show all posts
Showing posts with label FreeBSD. Show all posts

Monday, July 25, 2011

Proftpd on freebsd

let say you have 1 machine fresh install FreeBSD.
here the step by step to make this server as FTP server.

install proftpd

cd /usr/ports/ftp/proftpd
make config (depend on your setting & use)
make install (wait for several minutes)

after complete
rehash
setting up your proftpd
ee /usr/local/etc/proftpd.conf
my setting

# For more informations about Proftpd configuration
# look at : http://www.proftpd.org/
#
# This is a basic ProFTPD configuration file (rename it to
# 'proftpd.conf' for actual use. It establishes a single server
# and a single anonymous login. It assumes that you have a user/group
# "nobody" and "ftp" for normal operation and anon.

ServerName "ProFTPD Mediu"
ServerType standalone
DefaultServer on
ScoreboardFile /var/run/proftpd/proftpd.scoreboard

# Port 21 is the standard FTP port.
Port 21

# Use IPv6 support by default.
#UseIPv6 off

# Umask 022 is a good standard umask to prevent new dirs and files
# from being group and world writable.
Umask 022

# To prevent DoS attacks, set the maximum number of child processes
# to 30. If you need to allow more than 30 concurrent connections
# at once, simply increase this value. Note that this ONLY works
# in standalone mode, in inetd mode you should use an inetd server
# that allows you to limit maximum number of processes per service
# (such as xinetd).
MaxInstances 30

CommandBufferSize 512

# Set the user and group under which the server will run.
User nobody
Group nogroup

# To cause every FTP user to be "jailed" (chrooted) into their home
# directory, uncomment this line.
#DefaultRoot ~

# Normally, we want files to be overwriteable.
AllowOverwrite on

# Bar use of SITE CHMOD by default
DenyAll


# A basic anonymous configuration, no upload directories. If you do not
# want anonymous users, simply delete this entire section.

#########################################################################
# #
# Uncomment lines with only one # to allow basic anonymous access #
# #
#########################################################################

#
# User ftp
# Group ftp

### We want clients to be able to login with "anonymous" as well as "ftp"
# UserAlias anonymous ftp

### Limit the maximum number of anonymous logins
# MaxClients 10

### We want 'welcome.msg' displayed at login, and '.message' displayed
### in each newly chdired directory.
# DisplayLogin welcome.msg
# DisplayFirstChdir .message

### Limit WRITE everywhere in the anonymous chroot
# # DenyAll
#

#

# User guest
User ftp
# Group nobody
Group nogroup
AnonRequirePassword off
RequireValidShell off
UseFtpUsers off
# UserAlias anonymous guest
UserAlias anonymous ftp
UserAlias guest ftp
MaxClients 10
DenyAll

Umask 002
AllowAll

DenyAll

AllowAll

# Deny write access from all except trusted hosts.
##
## Order allow, deny
## Allow from 172.16.10.0.
## Deny from all
##

##


# FTPS
#Include /usr/local/etc/tls.conf

Monday, June 20, 2011

Freebsd apache rotation log / change directory

Freebsd apache rotation log / change directory

add this line at ee /etc/newsyslog.conf

# Rotating Apache log ~ Dipetik dari : http://mikkel.hoegh.org/blog/2009/oct/8/rotating-apache-httpd-logfiles-freebsd

#/var/log/httpd-access.log www:www 440 9 * $W1D4 J /var/run/httpd.pid 30
/data/log/httpd-access.log www:www 440 9 * $D11 J /var/run/httpd.pid 30
/var/log/httpd-error.log www:www 440 9 * $W1D4 J /var/run/httpd.pid 30


after adding at httpd.conf

search http-access.log

CustomLog "/data/log/httpd-access.log" combined


and adding / replace at vhost.conf (if you using vhost)

CustomLog "/data/log/httpd-access.log" common

Restart Apache

Thursday, April 7, 2011

SNMPD on freebsd

I'm using FreeBSD 8.2 and here's the basics for getting snmp working:

cd /usr/ports/net-mgmnt/net-snmp
make
make install
make clean

edit /etc/rc.conf
add snmpd_enable="YES"

cd /usr/local/share/snmp
edit snmpd.conf (you may have to create it)
add the following
syslocation home (replace home with whatever you'd like)
syscontact me@here.com (put in your e-mail or whatever)
rocommunity private (replace with whatever read only name you'd like)
rwcommunity public (again, change this to whatever you'd like)
master yes
now save and exit

cd /usr/local/etc/rc.d
./snmpd.sh start

This will get you up and running with a very basic snmp configuration. There's a handy utility called 'snmpconf' that can be run to help you generate the snmp.conf (optional) and snmpd.conf files. This will give you more options and help tighten up security.

at this point you should be able to snmpwalk your host
snmpwalk -v1 -c public 127.0.0.1

Sunday, February 27, 2011

FreeBSD Update from 7. (01234) or 8.(01)

FreeBSD Update

The freebsd-update(8) utility supports binary upgrades of i386 and amd64 systems running earlier FreeBSD releases. Systems running 7.[01234]-RELEASE, 8.[01]-RELEASE, 8.2-BETA1, or 8.2-RC[123] can upgrade as follows:

# freebsd-update upgrade -r 8.2-RELEASE

During this process, FreeBSD Update may ask the user to help by merging some configuration files or by confirming that the automatically performed merging was done correctly.

# freebsd-update install

The system must be rebooted with the newly installed kernel before continuing.

# shutdown -r now

After rebooting, freebsd-update needs to be run again to install the new userland components:

# freebsd-update install

At this point, users of systems being upgraded from FreeBSD 7.4-RELEASE or earlier will be prompted by freebsd-update to rebuild all third-party applications (e.g., ports installed from the ports tree) due to updates in system libraries.

After updating installed third-party applications (and again, only if freebsd-update printed a message indicating that this was necessary), run freebsd-update again so that it can delete the old (no longer used) system libraries:

# freebsd-update install

Finally, reboot into 8.2-RELEASE:

# shutdown -r now

** taken from FreeBSD Website

Thursday, August 19, 2010

Portupgrade

I learn something new from my sifoo

try to run portupgrade :

portupgrade /var/db/pkg/namepackage

make fetch-recursive-list

Wednesday, June 23, 2010

Change usr directory to other HDD / Partition

to change the usr directory in freebsd (i already make it)
add new hdd to your server, format it. let say i give the new patition is /usr2
after finish format

cd /usr2
dump 0af - /usr | restore rf -

After the dump completed, edited /etc/fstab.
Delete the line with /usr in /etc/fstab.
Updated the line with /usr2, changed /usr2 for /usr. (inside fstab)
Then rebooted. Finally the system started with a new /usr filesystem.

Done!

Credit to BSD Forum!

Tuesday, May 11, 2010

Netcat Tar

This is suitable if you don't have enough space on the source machine.

On sender :

tar -czf - directory-name | nc -l 3333

on receiver :

nc sender-ip-address 3333 > mybackup.tar.gz


Courtesy : Sifoo Zaman.

Change Login Directory (FreeBSD)

today i learn something.

How to change directory when login.

Login as root
setenv EDITOR ee (i need this because i don't know how to use VI in BSD)
type vipw
edit the directory at user you want to edit
save & exit

DONE

Thursday, May 6, 2010

Hidden Apache directory listing

If you are on an RPM installation of Apache (which i dont really recommend) you will find the apache configuration file probably here:

/etc/httpd/conf/httpd.conf

If you are using apache from the source tar balls ( like real men ) probably you will find the configuration file here:

/usr/local/apache/conf/httpd.conf

Using an editor like vi , edit the httpd.conf file and scroll until you find a line like this:

Options All Indexes FollowSymLinks MultiViews

To disable directory browsing carefully remove the line that says: Indexes and leave the line like this:

Options All FollowSymLinks MultiViews

Restart your apache webserver and thats it

reference http://www.felipecruz.com/blog_disable-directory-listing-browsing-apache.php

Wednesday, April 21, 2010

How To Rsync at Freebsd Using ssh.

Before rsync,your have to make sure your BSD box already insttaled rsync. If you don't have it please to do so and please to install both of your server.

You can install rsync using ports (Please to csup your ports 1st to get the new packages)

#cd /usr/ports/net/rsync/
#make config
#make && make install
#rehash.

Start to rsync.

i am only rsync forder usr/src.
#rsync -av -e "ssh -l admin" root@servername:/usr/src/ /usr/src/

After finish do not reboot, please re-compile.
** I recommended to csup the stable_supfile 1st before your compile your kernel.

#cd /usr/src
#make cleanworld && make cleandir
#make buildworld
#make buildkernel KERNCONF=YOUR_KERNEL_HERE' (default is GENERIC).
#make installworld
#make installkernel KERNCONF=YOUR_KERNEL_HERE' (default is GENERIC).
#reboot

Then start to rsync other folder.
Your can exclude any folder that you think not necessary.
I am rsync some folder such as boot or usr/src.

#rsync -av --exclude=/boot --exclude=/usr/src -e "ssh -l admin" root@servername:/ /

password will be prompted. Then enter password. wait until finish the rsync.

After finish

change ip address,hostname and vhost.

To change hostname.
#ee /etc/hosts

To change ip address
#ee /etc/rc.conf

to change vhost ** If you use it.
# ee /usr/local/etc/apache22/extra/httpd-vhosts.conf

then reboot your server

Tuesday, March 16, 2010

Backup filesystem using dumpfs (FreeBSD)

finally i got to backup filesystem using dumpfs

- i got script from this web http://my.galagzee.com/2009/07/17/freebsd-dump-filesystem-shell-script/
- touch a new file name "dumpfs.sh" and put at /usr/local/sbin/
- paste the script inside dumpfs.sh
- set at /etc/crontab

to restore from backup dumps
- restore rf 20100305_0


reference :
- http://my.galagzee.com/2009/07/17/freebsd-dump-filesystem-shell-script/

Monday, March 8, 2010

Change location HDD from original VM to another VM

If you have 1 server seperate 2 HDD example 1 for OS & another for data. Let talk about when the OS have a problem than how gonna you take out the HDD data to another VM machine. So this tutorial i made for me and for you as a knowledge tp know.

server A - original server have 2 HDD
server B - server

scenario

- when OS in server A crash or corrupted, don't panic! here the step. your data is save because you have a separated HDD on your VM.
- firstly create your new VM, install OS (for me i using Freebsd) after finish please add another HDD when the installation is completed. so now you have 2 HDD (the size on additional HDD depend on your server & need (in my case i create same capacity with the original server capacity for data))
- log in into server B and format the HDD using sysinstall (fdisk & label) the HDD. (remember to add at /etc/fstab for your new HDD)
- after finish format, open VM client browse the datastore your server A located.
- copy the second HDD.vmdk ( by default your HDD will namely nameserver_1.vmdk) copy this file and browse the folder server B & paste inside the folder server B.
- after finish copy you need to rename your the vmdk file that you copy from server B. To this try to ssh inside the vmware machine, by default your vm not allow the ssh protocol you need to open it.
- ssh your VM, go to /vmfs/volumes/datastore1 , go to path your server directory
- backup the nameserverB_1.vmdk to nameserverB_1ORI.vmdk
- rename the vmdk that you copy before nameserverA_1.vmdk to nameserverB_1.vmdk
- turn on your VM.

DONE

Monday, March 1, 2010

FreeBSD (add extra HDD on VMWare Environment)

FreeBSD add another HDD on VMWARE and format it

- shutdown your server.
- open your vmware & choose the server you want to add
- edit & add HDD
- Turn on your server.
- become as root type sysinstall
- choose configure & FDISK
- choose a additional HDD that you add before. (BEWARE!!! Do not edit the existing HDD on your server,this may cause your server corrupted!)
- choose entire disk if you want to use all disk & W button (write)
- please choose NONE "do not tpuch master boot record"
- after finish push q button
- go back to main menu & choose Label (this is use to label your HDD)
- select C to create the FS (depend on your need) exp : /test01
- and select W to write the changes
- Select Q and edit at FSTAB (ee /etc/fstab)
- add this line to you fstab line
exp : /dev/da1s1 /test01 ufs rw 2 2
- save and reboot your server.

Tuesday, February 9, 2010

SUDO on FreeBSD

as root install

sudo located at /usr/ports/security/sudo
make configure
make && make install

edit conf at

ee /usr/local/etc/sudoers

example and edit :

# Runas alias specification

# User privilege specification
root ALL=(ALL) ALL
kenan ALL=(www) ALL

note :

This Sudo command limits the user's power on the basis of the configuration made on the file "/etc/sudoers".
Generally in default case you might see something like this:

root ALL=(ALL) ALL
Above, you can see ALL 3 times. But what does it mean?
The first ALL: Run from any(all) host
The Second ALL: From any Terminal
The third ALL: Can Run any command

example :
usename ALL=(group) ALL


** note : !/usr/bin/su (this will prevent user to sudo su)

General sudoers File Record Format
usernames/group servername = (usernames command can be run as) command

Lock / Unlock user on FreeBSD

Lock user :

pw lock nameuser

unlock user :

pw unlock nameuser

Tuesday, January 19, 2010

Rollback with MySQL Transaction Log

Yesterday was a Grey Monday (almost turning into Black Monday)..

It happened that one of the MySQL DB was not backed-up and to make things more thrilling, one the table on the db was compromised.
Alhamdulillah, again, Zaman came to save the day.

Here what we did to rollback the transaction using the transaction log :

  1. Read the transaction log in /var/db/myql/hostname-bin.xxxxxx
    This is binary format. In order to read the file, you have to use mysqlbinlog command :

    mysqlbinlog mysql-bin.000001

    This will show every single transaction happened on that particular server.

  2. Then setup new MySQL server (I strongly advise you to setup a new database since we do not want to mess the existing one.)

  3. Dump the compromised db structure only (without data) then restore it in the new server.

  4. Then simply run the mysqlbinlog command and extend it to restore back to the server :

    mysqlbinlog mysql-bin.xxxxxx --database=yourdbname | mysql -uroot -p yourdbname

    If you want to exclude the last transaction which normally will be the culprit, you can use --stop-datetime option. You should know when is the last point/time (before the culprit transaction) of the transaction.



    By reading the transaction log, you will find the timestamp provided by MySQL. For example : 1263759884

    Since mysqlbinlog format needs human readable format, you have to convert the timestamp to human readable format. Here is one of the online date converter :

    http://www.epochconverter.com/

    Once converted, append it into the command :



    mysqlbinlog mysql-bin.000024 --database=yourdbname --stop-datetime="2010-01-17 22:11:16" | mysql -uroot -p yourdbname

    That's it.

Wednesday, January 13, 2010

Add HDD on VMWARE (FreeBSD)

I just finish adding HDD onto my Vmware server.

the step :

- choose vm that you wish to add the HDD
- edit setting
- add and choose HDD
- follow the instruction
- after adding go to server (freebsd)
- type sysinstall
- choose fdisk
- BEWARE! please make sure your HDD before you format it!
- after you choose your HDD, choose A and W (write the HDD)
- after finish,exit and choose label
- choose C (create) , edit the label and W (write) the HDD.
- edit the fstab (ee /etc/fstab)

example :
but beware too remember the path your HDD before edit the fstab.

/dev/da1s1d /data ufs rw 2 2

- save and reboot.

Setting in FSTAB add HDD in FreeBSD or Unix

ee /etc/fstab

/dev/da2s1 /studentdata ufs rw 2 2

Sunday, January 10, 2010

SUDO in FreeBSD / Unix

as root install

sudo located at /usr/ports/security/sudo
make configure
make && make install

edit conf at

ee /usr/local/etc/sudoers

example and edit :

# Runas alias specification

# User privilege specification
root ALL=(ALL) ALL
kenan ALL=(www) ALL

example :
usename ALL=(group) ALL


** note : !/usr/bin/su (this will prevent user to sudo su)

Set environment : setenv EDITOR ee


General sudoers File Record Format
usernames/group servername = (usernames command can be run as) command

Wednesday, January 6, 2010

Check RAM on FreeBSD

Install :

# cd /usr/ports/sysutils/freecolor
# make install clean

$ freecolor -m -o