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
Friday, January 29, 2010
How to login with SSH without enter password
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
Sunday, August 30, 2009
[Linux] เพิ่มความสามารถให้ squid cache video ได้
This summary is not available. Please click here to view the post.
Thursday, June 11, 2009
[Linux] script สำหรับ check process แบบง่ายๆๆๆๆ
สืบเนื่องมาจากเปิด transmission-daemon ไว้แล้วมัน crash บ่อยเลยอยากให้มี script ไว้ตรวจสอบแล้ว restart อัติโนมัติ
[Linux] ใช้ wireshark บน text mode
ผมติดการใช้งาน wireshark แต่พอดีมาใช้บน linux แล้วเป็น text mode command line ใช้ tcpdump มันแสดงผลไม่สวยเห็น wireshark มีบน text เหมือนกันชื่อ tshark
Tuesday, January 20, 2009
[Linux] ทำ FTP caching
ต้องการทำ ftp caching ให้ install package frox
vi /etc/frox.conf
Listen 0.0.0.0
Port 2121
ResolvLoadHack wontresolve.doesntexist.abc
TcpOutgoingAddr 192.168.1.100
#^-- ifconfig eth0:1 inet 192.168.1.100 netmask 255.255.255.255 up
User frox
Group frox
WorkingDir /var/spool/frox
LogLevel 20
LogFile /var/spool/frox/frox-log
PidFile /var/run/frox.pid
APConv yes
BounceDefend yes
CacheModule local
CacheSize 10240
CacheAll yes
CacheOnFQDN yes
MaxForks 10
MaxForksPerHost 10
ACL Allow * - *
Thursday, December 4, 2008
[Linux] Compile cacti-spine แล้ว error
ผมใช้ ubuntu 8.10 เวลาจะ compile cacti-spine เองมัน error
ubuntu@hybitz:~/cacti-spine-0.8.7a$ ./configure
configure: error: cannot run /bin/bash config/config.sub
วิธีแก้คือ
aclocal
autoheader
libtoolize --force
automake --add-missing
autoconf
./configure
make
make install
Monday, May 19, 2008
[Ubuntu] tunning hardy 8.04 for my labtop
sudo vi /etc/fstab
UUID=fdb68ba3-e411-4a71-8cb4-ac4e117181de / reiserfs notail,relatime 0 1
change to
UUID=fdb68ba3-e411-4a71-8cb4-ac4e117181de / reiserfs notail,noatime,relatime 0 1
sudo vi /etc/sysctl.conf
vm.swappiness=0
sudo vi /etc/init.d/rc
CONCURRENCY=shell
sudo vi /boot/grub/menu.lst
# defoptions=quiet splash
change to
# defoptions=quiet splash elevator=cfq ramdisk_size=160000
And run
sudo update-grub
sudo apt-get install preload prelink bootchart
sudo vi /etc/default/prelink
PRELINKING=unknown
change to
PRELINKING=yes
when reboot, view images
/var/log/bootchart
Disable ipv6
sudo vi /etc/modprobe.d/aliases
#alias net-pf-10 ipv6
alias net-pf-10 off ipv6
alias net-pf-10 off
alias ipv6 off
if you want disable check filesystem (fsck)
sudo touch /fastboot
force check
sudo touch /forcefsck
!-------------------------------------------------------------------
vi fastboot
#! /bin/sh
### BEGIN INIT INFO
# Provides: fastboot
# Required-Start: networking
# Required-Stop: networking
# Should-Start:
# Should-Stop:
# Default-Start: 2 3 4 5
# Default-Stop: 0
# Short-Description: create/delete file /fastboot .
### END INIT INFO
PATH=/sbin:/bin
. /lib/lsb/init-functions
do_start () {
log_begin_msg "Deleting /fastboot file ..."
rm -f /fastboot
}
do_stop () {
log_begin_msg "Creating /fastboot file ..."
touch /fastboot
}
case "$1" in
start)
do_start
;;
restart|reload|force-reload)
echo "Error: argument '$1' not supported" >&2
exit 3
;;
stop)
do_stop
;;
*)
echo "Usage: $0 start|stop" >&2
exit 3
;;
esac
!-------------------------------------------------------------------
sudo apt-get install sysv-rc-conf
cp fastboot /etc/init.d
sudo sysv-rc-conf
check level 2,3,4,5
Friday, April 11, 2008
[Cisco] config cisco กับ tacacs+
ต้วอย่างการ config cisco กับ tacacs+ เพื่อ authen, authorize user ที่ login เข้ามาใช้งาน อุปกรณ์
aaa new-model
aaa authentication login default none
aaa authentication login AUTH_TACACS group tacacs+ local
aaa authentication enable default group tacacs+ enable
aaa authorization config-commands
aaa authorization exec default none
aaa authorization exec AUTH_TACACS group tacacs+ local none
aaa authorization commands 1 AUTH_TACACS group tacacs+ local none
aaa authorization commands 15 AUTH_TACACS group tacacs+ local none
aaa accounting exec AUTH_TACACS start-stop group tacacs+
aaa accounting commands 1 AUTH_TACACS start-stop group tacacs+
aaa accounting commands 15 AUTH_TACACS start-stop group tacacs+
tacacs-server host 192.168.1.2
tacacs-server key TACACS_KEY
line vty 0 4
authorization commands 1 AUTH_TACACS
authorization commands 15 AUTH_TACACS
authorization exec AUTH_TACACS
login authentication AUTH_TACACS
!-----------------------------------------
! tac_plus.cfg
key = TACACS_KEY
default authentication = file /etc/passwd
accounting file = /var/log/tac_acc.log
user = $enab15$ {
login = cleartext "enable15"
}
######### GROUP DECLARATION #########
group = Administrator {
default service = permit
# example configuration for authorize commands
cmd = ping {
permit .*
}
cmd = reload {
deny .*
}
cmd = write {
deny .*
}
cmd = copy {
deny .*
}
cmd = show {
deny config
deny running
permit .*
}
cmd = ip {
deny "route 0.0.0.0 0.0.0.0"
permit .*
}
cmd = username {
deny .*
}
cmd = enable {
deny password
deny secret
permit .*
}
cmd = no {
deny "ip route 0.0.0.0 0.0.0.0"
deny "username .*"
deny "enable password .*"
deny "enable secret .*"
permit .*
}
}
user = kitti { service = exec { priv-lvl =15 } member = Administrator }
Friday, February 8, 2008
[Linux] เวลาเราใช้ vmware เพื่อใช้ emu Olive เจอปัญหาเรื่อง console
เวลาเราใช้ vmware เพื่อ emulation Olive ซึ่งโดย default แล้ว olive จะ input/output ทาง console ฉะนั้นทำให้เราไม่สามารถ console กับ vmware ได้
1. ที่ vmware ทำการ add serial port โดยเป็น name pipe
path= /tmp/com1
This end is the server
This other end is an application
2. install software name socat
sudo apt-get install socat
3. run socat
socat -d -d /tmp/com1 pty <-- socat จะทำการ emulate /dev/pts/? จากนั้นเราใช้ minicom use port /dev/pts/?
4. minicom -s
Monday, August 6, 2007
[MySQL] Mysql replicate DB
mysql สามารถ replicate DB ได้ A<=====>B
Server A:
vi /etc/my.cnf
[mysqld]
log-bin
server-id=1
master-host=192.168.1.1
master-user=replicate
master-password=replicatepass1
replicate-do-db=DB
slave-skip-errors=1050 <<< skip error table exist
Server B:
vi /etc/my.cnf
[mysqld]
log-bin
server-id=2
master-host=192.168.1.2
master-user=replicate
master-password=replicatepass1
replicate-do-db=DB
slave-skip-errors=1050
ทั้ง 2 server ต้องมี tables เหมือนกันโดยจะต้อง create database ก่อน และจะต้อง grant สิทธ์ของ user สามารถ update ข้อมูลกันได้ mysql>create database DB;
mysql>user DB;
mysql>create table 'test' (
`id` int(10) NOT NULL auto_increment,
'name' varchar(32) default '',
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
mysql>load data from master;
command ต่างๆ
mysql>show slave status\G;
mysql>show master status\G;
mysql>start slave;
mysql>stop slave;
mysql>reset slave;
Friday, July 27, 2007
[Linux] เริ่มต้นกับ Ubuntu(feisty) และ DELL LATITUDE D620
h**ps://wiki.ubuntu.com/LaptopTestingTeam/DellLatitudeD620
Thursday, May 24, 2007
[Linux] Squid จะต้องการให้มีการ redirect url โดยดูจาก source ip
จะใช้ squid ทำตัวเป็น redirector โดยให้ดูจาก rule ที่กำหนด
#vi /etc/squid/squid.conf
url_rewrite_program /home/kitti/squid_redirect.pl
#vi /home/kitti/squid_redirect.pl
#!/usr/bin/perl
$|=1;
sub print_log
{
local($msg) = @_;
($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst)=localtime(time);
$time=sprintf "%4d-%02d-%02d %02d:%02d:%02d",$year+1900,$mon+1,$mday,$hour,$min,$sec;
open(LOG,"+>>$log_file");
print LOG "$time : $msg";
close(LOG);
}
$rules_file = "/etc/squid/rules.conf";
$log_file = "/var/log/squid/redirect.log";
open (RULE,$rules_file);
&print_log("-- redirector start --\n");
while (<>) {
@X = split;
seek(RULE,0,0);
$url = $X[0];
($ip,$fqdn) = split(/\//,$X[1]);
$number=1;
$flag=0;
$line_no=0;
$go_url = $url;
while(
chomp;
$line = $_;
if((!($line =~ /^[\#\;\t ]/))&&($line)){
($src_ip,$dst_url,$action,$redirect) = split(/[ |\t]+/,$line);
if(($url =~ /$redirect/)&&($ip =~ /$src_ip/)) {
$flag = 1;
$go_url = $url;
$action = "direct-to";
}elsif (($url =~ /$dst_url/)&&($ip =~ /$src_ip/)) {
$line_no = $number;
if($action eq 'bypass'){
$go_url = $url;
$flag = 1;
}elsif ($action eq 'redirect-to'){
$go_url = "302:$redirect";
$flag = 1;
}
}
}
$number++;
if($flag){ last; }
}
print "$go_url\n";
#&print_log("squid request: @X\n");
&print_log("ip:$ip, url:$url, rule:$line_no, action:$action, redirect:$go_url\n");
}
close(RULE);
&print_log("-- redirector exit-- \n");
exit(0);
#===============================================================
#vi /etc/squid/rules.conf
# description
;src-ip url action
1.1.1.1 www.domain1.com bypass
127.0.0.1 www.domain2.co.th bypass
.* www.domain3.com bypass
.* domain4.co.th bypass
.* .* redirect-to http://www.default-domain.co.th
Thursday, May 17, 2007
Wednesday, May 16, 2007
[Linux] ใช้ firefox บน ubuntu แล้วเปิด Link ที่เป็น telnet:// ไม่ได้
อันเนื่องมาจากเปิด www.traceroute.org แล้วจะให้ firefox เรียก telnet ขึ้นมาให้เลย
1. ที่ address bar พิมพ์ about:config
2. click ขวา แล้วเลือก new->boolean
network.protocol-handler.external.telnet = true แล้ว Ok
3. click ขวาเพิ่มอีก new->string
network.protocol-handler.app.telnet = /usr/bin/firefox-telnet.sh
4. sudo vi /usr/bin/firefox-telnet.sh
#!/bin/bash
gnome-terminal -e "telnet ${1##telnet://}"
Monday, April 9, 2007
[MySQL] ใช้ command line แก้ไข column size
กันลืม ใช้บ่อยมากเวลาแก้ไข column size
ALTER TABLE foo MODIFY column FOO ...
I would just use TEXT or TINYTEXT but if you wanted
only 1000 chars, you would use VARCHAR(1000);
Friday, March 30, 2007
[Linux] เวลาเอาไฟล์จาก dos มาใช้บน linux แล้วเห็น ^M
มักจะมีปัญหาว่าเอาไฟล์จาก dos มาใช้ใน linux แล้วเห็นเป็น ^M อยากจะเอามันออก
#col -bx < dos-filename > new-filename
[Linux] จะใช้ console ผ่าน com1 กับ linux
อยากทำเท่ config linux ผ่าน console เหมือนพวก router
vi /etc/grub.conf
serial --unit=0 --speed=9600
terminal --timeout=15 console serial
บรรทัด kernel ต่อท้ายบรรทัดด้วย console=tty0 console=ttyS0
ถ้า loader ใช้ lilo
vi /etc/lilo.conf
serial = 0,9600n8
append = "console=ttyS0,9600n8"
vi /etc/inittab
S1:12345:respawn:/sbin/agetty -L ttyS0 9600 vt100
vi /etc/securetty
! เอา remark ออกตรง ttyS0 เพื่อให้ root สามารถ login ได้
[Linux] เคยดู log ของ Squid แล้วอยากดู timestamp ที่มันรู้เรื่องหน่อย
vi converttime.pl
#!/usr/bin/perl -p
s/^\d+\.\d+/localtime $&/e;
เวลาใช้งาน
#./converttime.pl access-log
ค่อยรู้เรื่องหน่อย
Thursday, March 29, 2007
[Linux] เขียนแต่ cisco มาเยอะแล้วอยากเก็บ script firewall ง่ายๆเอาใว้ใช้เอง
เขียนแต่ cisco มาเยอะแล้วอยากเก็บ script firewall ง่ายๆเอาใว้ใช้เอง เวลา install linux จะได้ copy ไปใช้เลย
#vi rc.firewall
#! /bin/sh
export PATH="${PATH:+$PATH:}/usr/sbin:/sbin"
do_start() {
iptables -A INPUT -i lo -j ACCEPT
## syn-flodding protection
iptables -N syn-flood
iptables -A INPUT -p tcp --syn -j syn-flood
iptables -A syn-flood -m limit --limit 1/s --limit-burst 4 -j RETURN
iptables -A syn-flood -j LOG --log-prefix "FIREWALL SYN-FLOOD: "
iptables -A syn-flood -j DROP
iptables -A INPUT -p udp -m udp -s 0/0 --sport 53 -d 0/0 -j ACCEPT
## Make sure NEW tcp connections are SYN packets
iptables -A INPUT -p tcp ! --syn -m state --state NEW -j DROP
iptables -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
## Allow deluge bittorrent open tcp port 53045
iptables -A INPUT -p tcp -m tcp --dport 53045 --syn -j ACCEPT
## Allow ssh open tcp port 22
iptables -A INPUT -p tcp -m tcp --dport 22 --syn -j ACCEPT
iptables -A INPUT -p udp -j LOG --log-prefix "FIREWALL UDP-IN: "
iptables -A INPUT -p udp -j DROP
iptables -A INPUT -p icmp -j LOG --log-prefix "FIREWALL ICMP-IN: "
iptables -A INPUT -p icmp -j DROP
iptables -A INPUT -p tcp -j LOG --log-prefix "FIREWALL TCP-IN: "
iptables -A INPUT -p tcp -j DROP
iptables -A INPUT -j LOG --log-prefix "FIREWALL PROTO-X-IN: "
iptables -A INPUT -j DROP
}
do_stop() {
iptables -F
iptables -X
iptables -Z
}
case "$1" in
start)
echo "Starting Firewall..."
do_start
;;
stop)
echo "Stopping Firewall..."
do_stop
;;
restart)
echo "Restarting Firewall..."
do_stop
sleep 2
do_start
;;
*)
echo "Usage: $0 {start|stop|restart}"
exit 1
esac
exit 0