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

Friday, January 29, 2010

How to login with SSH without enter password


How to login with SSH without enter password
[Client]
$ssh-keygen -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/Users/XXXX/.ssh/id_rsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:

$scp .ssh/id_rsa.pub mylogin@192.168.1.1:.ssh/authorized_keys
Password:

#Testing
$ssh mylogin@192.168.1.1

Thursday, October 1, 2009

[Lighttpd] Config lighttpd support SSL

Test on FreeBSD 7.2
lighttpd-1.4.22 (ssl) - a light and fast webserver
Build-Date: Apr 18 2009 13:02:03

1. Generate key
#mkdir /etc/ssl/private
#cd /etc/ssl/private/
#openssl req -new -x509 -keyout lighttpd.pem -out lighttpd.pem -days 365 -nodes

2. vi /usr/local/etc/lighttpd.conf
# Uncomment mod_redirect in server.modules.

$SERVER["socket"] == "0.0.0.0:443" {
#### SSL engine
ssl.engine = "enable"
ssl.pemfile = "/etc/ssl/private/lighttpd.pem"
}
else $HTTP["host"] =~ "(.*)" {
url.redirect = ( "^/(.*)" => "https://%1/$1" )
}


3. Start lighttpd
#/usr/local/etc/rc.d/lighttpd restart

Thursday, August 13, 2009

[FreeBSD] ลงโปรแกรม netatalk เอาไว้ share ให้ mac

# pkg_add -r netatalk
# vi /usr/local/etc/pam.d/netatalk
###

netatalk auth required pam_unix.so try_first_pass
netatalk account required pam_unix.so try_first_pass
netatalk session required pam_permit.so
###
vi /etc/rc.conf

netatalk_enable="YES"
atalkd_enable="NO"
papd_enable="NO"
cnid_metad_enable="NO"
afpd_enable="YES"
timelord_enable="NO"

#---- start service
#/usr/local/etc/rc.d/netatalk start

จากนั้นก็ใช้ mac ทำการ connect โดยเปิด finder-> Go -> Connect to server ,
Server address: afp://username@192.168.1.1 --> Connect

Wednesday, August 12, 2009

[FreeBSD] Create RamDisk on FreeBSD

vi mkramdisk.sh

#!/bin/sh
MOUNT_DIR="/dynamips/cache"
SIZE=512M

case "$1" in
start)
/sbin/mdmfs -S -s $SIZE md0 $MOUNT_DIR
echo "$SIZE ramdisk created on /dev/md0 and mounted on $MOUNT_DIR"
exit 0
;;
stop)
/sbin/umount $MOUNT_DIR
/sbin/mdconfig -d -u 0
echo "ramdisk unmounted from $MOUNT_DIR and deleted from /dev/md0"
;;
restart)
$0 stop
$0 start
;;
*)
echo "Usage: `basename $0` {start|stop|restart}" >&2
exit 64
;;
esac

[FreeBSD] Example /etc/pf.conf

vi /etc/rc.conf
pf_enable="YES" <== enable pf

vi /etc/pf.conf
## Macros
SYN_ONLY="S/FSRA"
EXT_NIC="bge0"
INT_NIC="bge1"

ALLOWED_ICMP="echoreq"
ALLOWED_TCP="{ 22,80 }"
TRUSTED_IP="{ 10.0.0.0/24, 1.1.1.1 }"

# Your Internet IP goes in the EXT_IP variable
EXT_IP="1.2.3.4"

# Your private network IP goes in the INT_IP variable
# if you have two NICs on the machine
INT_IP="192.168.1.1"

## TABLES


## GLOBAL OPTIONS
set block-policy drop

## TRAFFIC NORMALIZATION


## QUEUEING RULES


## TRANSLATION RULES (NAT)


## FILTER RULES

# Block everything (inbound AND outbound on ALL interfaces) by default (catch-all)
block all

# Default TCP policy
block return-rst in log on $EXT_NIC proto TCP all
pass in log quick on $EXT_NIC proto TCP from any to $EXT_IP port $ALLOWED_TCP flags $SYN_ONLY keep state

# Default UDP policy
block in log on $EXT_NIC proto udp all
# It's rare to be hosting a service that requires UDP (unless you are hosting
# a dns server for example), so there typically won't be any entries here.

# Default ICMP policy
block in log on $EXT_NIC proto icmp all
pass in log quick on $EXT_NIC proto icmp from any to $EXT_IP icmp-type $ALLOWED_ICMP keep state

# Default IP Policy
block in log on $EXT_NIC all
pass in log quick on $EXT_NIC from $TRUSTED_IP to $EXT_IP keep state

block out on $EXT_NIC all
pass out quick on $EXT_NIC from $EXT_IP to any keep state

# Allow the local interface to talk unrestricted
pass in quick on lo0 all
pass out quick on lo0 all

Thursday, May 21, 2009

[Juniper] How to simulate JUNOS w/ FreeBSD & VirtualBox on MacBook or Linux

How to simulate JUNOS w/ FreeBSD & VirtualBox on MacBook or Linux
Requiements:
JUNOS: jinstall-8.5R1.4-domestic-signed.tgz
FreeBSD: 4.10-RELEASE-i386-miniinst.iso
VirtualBox
Socat (install via macports, apt-get) <-- By default olive disable standard output, only management with serial port console

Credit:
h**p://brokenpipes.blogspot.com
h**p://www.packetmischief.ca/juniper/olive/
h**p://spirit.sheridanc.on.ca/help/virtualbox/Network_Between_VirtualBox_Machines.html

1. VirtualBox
1.1 Create VM
Name JuniperOlive
Operating system: BSD
Version: FreeBSD
1.2 Memory size 256M
1.3 Create new harddisk
- Dynamic expanding storage
- Location
- Size 3G
1.4 Config detail
1.4.1 Audio disabled
1.4.2 Network
- Adapter 1
-Adapter type: Intel PRO/1000MT Desktop
-Attached to: NAT
- Adapter 2
-Adapter type: Intel PRO/1000MT Desktop
-Attached to: Internal Network
-Name: intf_R1_R2
- Adpater 3
-Adapter type: Intel PRO/1000MT Desktop
-Attached to: Internal Network
-Name: intf_R1_R3
1.5 Serial Ports
Enable ports 1
Port number: COM1
Port mode: Host Pipe
Check Create Pipe
Path: /tmp/olive1
2. Install FreeBSD
2.1 Boot freebsd cd
2.2 Skip kernel configuration
2.3 Choose standard install
2.4 Fdisk, Press A, then Q
2.5 select: install a standard MBR
2.6 Create partitions, Press C

/ FS 500M
SWAP 500M
/config FS 100M
/var FS
Finish press Q.
2.7 Choose Distributions = Exit
2.8 Install media CD/DVD
2.9 Config Ethernet: Yes
2.10 Network Interface
2.8.1 select em0 for DHCP, no ipv6
2.8.2 enter hostname: olive, then OK
2.8.3 select NO any requested
2.8.4 Set root password YES, Add user & group= Exit
2.11 Exit from install

2. Install JUNOS software
2.1 Boot freebsd and login with root
#cd /var/tmp
#ftp x.x.x.x <-- get junos software
get jinstall-8.5R1.4-domestic-signed.tgz
#mkdir jinst-signed
#cd jinst-signed
#tar xvfz ../jinstall-8.5R1.4-domestic-signed.tgz
#mkdir jinst
#cd jinst
#tar xvfz ../jinstall-8.3R1.4-domestic.tgz
#mkdir pkgtools
#cd pkgtools
#tar xvfz ../pkgtools.tgz
#cd bin
#cp /usr/bin/true checkpic
#cd ..
#tar zcvf ../pkgtools.tgz *
#cd ..
#rm -rf pkgtools
#tar zcvf /var/tmp/jinstall-8.3R1.4-domestic-signed-olive.tgz *
#rm /dev/wd0c && ln -s /dev/ad0c /dev/wd0c
#mkdir /var/etc
#touch /var/etc/master.passwd
#touch /var/etc/group
#touch /var/etc/inetd.conf
! install JUNOS
#pkg_add /var/tmp/jinstall-8.3R1.4-domestic-signed-olive.tgz
! reboot to continue



3. VirtualBox clone VDI for Backup & for R2 R3 ..
On MacBook

$ cd Library/VirtualBox/VDI/
$ VBoxManage clonehd JuniperOlive.vdi JuniperOlive_R1.vdi
VirtualBox Command Line Management Interface Version 2.2.2
(C) 2005-2009 Sun Microsystems, Inc.
All rights reserved.

0%...10%...20%...30%...40%...50%...60%...70%...80%...90%...100%
Clone hard disk created in format 'VDI'. UUID: 564eefe7-350f-42a3-bfd2-bb967d2f998e
3.1 New VM name JuniperOlive_R2, JuniperOlive_R3 and select harddisk from clone
3.2 Config VirtualBox JuniperOlive_R2, JuniperOlive_R3 details same JuniperOlive_R1
- Set Serial ports path different from R1, such as path: /tmp/olive2, /tmp/olive3

4. Start Olive
on macbook open new terminal
$socat -d -d /tmp/olive1 pty <-- Create new PTY. Example /dev/ttys001
$minicom -o -s <-- console and setup select port /dev/ttys001
5. Finish



Thursday, April 24, 2008

[FreeBSD] Basic commands for pfctl

# basic pfctl control
# ==
# This document: http://www.rdrs.net/document/
# Related: http://www.OpenBSD.org
# Last update: Tue Dec 28, 2004
# ==
# Note:
# this document is only provided as a basic overview
# for some common pfctl commands and is by no means
# a replacement for the pfctl and pf manual pages.

#### General PFCTL Commands ####

# pfctl -d disable packet-filtering
# pfctl -e enable packet-filtering
# pfctl -q run quiet
# pfctl -v -v run even more verbose

#### Loading PF Rules ####
# pfctl -f /etc/pf.conf load /etc/pf.conf
# pfctl -n -f /etc/pf.conf parse /etc/pf.conf, but dont load it
# pfctl -R -f /etc/pf.conf load only the FILTER rules
# pfctl -N -f /etc/pf.conf load only the NAT rules
# pfctl -O -f /etc/pf.conf load only the OPTION rules

#### Clearing PF Rules & Counters ####
# pfctl -F all flush ALL
# pfctl -F rules flush only the RULES
# pfctl -F queue flush only queue's
# pfctl -F nat flush only NAT
# pfctl -F info flush all stats that are not part of any rule.
# pfctl -z clear all counters
# note: flushing rules do not touch any existing stateful connections

#### Output PF Information ####
# pfctl -s rules show filter information
# pfctl -v -s rules show filter information for what FILTER rules hit..
# pfctl -vvsr show filter information as above and prepend rule numbers
# pfctl -v -s nat show NAT information, for which NAT rules hit..
# pfctl -s nat -i xl1 show NAT information for interface xl1
# pfctl -s queue show QUEUE information
# pfctl -s label show LABEL information
# pfctl -s state show contents of the STATE table
# pfctl -s info show statistics for state tables and packet normalization
# pfctl -s all show everything

#### Maintaining PF Tables ####
# pfctl -t addvhosts -T show show table addvhosts
# pfctl -vvsTables view global information about all tables
# pfctl -t addvhosts -T add 192.168.1.50 add entry to table addvhosts
# pfctl -t addvhosts -T add 192.168.1.0/16 add a network to table addvhosts
# pfctl -t addvhosts -T delete 192.168.1.0/16 delete nework from table addvhosts
# pfctl -t addvhosts -T flush remove all entries from table addvhosts
# pfctl -t addvhosts -T kill delete table addvhosts entirely
# pfctl -t addvhosts -T replace -f /etc/addvhosts reload table addvhosts on the fly
# pfctl -t addvhosts -T test 192.168.1.40 find ip address 192.168.1.40 in table addvhosts
# pfctl -T load -f /etc/pf.conf load a new table definition
# pfctl -t addvhosts -T show -v output stats for each ip address in table addvhosts
# pfctl -t addvhosts -T zero reset all counters for table addvhosts

Thursday, February 28, 2008

[FreeBSD] FreeBSD 7.0 ออกแล้ว

วันนี้ผมเข้าไปดู freebsd ปรากฏว่า freebsd 7.0 ออกแล้ว ซึ่งดูจาก release announce แล้วดูดีมากเลยครับสำหรับไปใช้กับ multiprocessing

Dramatic improvements in performance and SMP scalability shown by various database and other benchmarks, in some cases showing peak performance improvements as high as 350% over FreeBSD 6.X under normal loads and 1500% at high loads. When compared with the best performing Linux kernel (2.6.22 or 2.6.24) performance is 15% better. Results are from benchmarks used to analyze and improve system performance, results with your specific work load may vary. Some of the changes that contribute to this improvement are:

  • The 1:1 libthr threading model is now the default.

  • Finer-grained IPC, networking, and scheduler locking.

  • A major focus on optimizing the SMP architecture that was put in place during the 5.x and 6.x branches.

h**p://www.freebsd.org/releases/7.0R/announce.html

Friday, April 13, 2007

[FreeBSD] พอ install OS แล้วผมก็เตรียมพร้อมสำหรับโหลดบิต

ต้องทำให้เครื่อง pentium3 แรงๆเพื่อจะได้โหลดบิต (ทำแบบมั่วๆ search ใน google เรื่อง optimize, tunning บ้างมารวมๆกัน)

Thursday, April 12, 2007

[FreeBSD] ต้องการ compile Kernel ใหม่แต่ตอน Install เราไม่ได้เลือกให้ลง src

#/usr/sbin/sysinstall
- configure -> Distributions -> src -> All -> Ok -> FTP or CD/DVD
เมื่อเสร็จแล้ว
/usr/src/sys/i386/conf