Tuesday 25 January 2011

CentOS 5에서 NTFS 파티션 마운트하기

일반적인 리눅스 배포본이라면 ntfs-3g라는 패키지를 대부분 설치하여 사용 가능하다.

하지만 Redhat Enterprise Linux(RHEL) 의 Free(?) 판인 CentOS는 기본 설정 만으로는 ntfs-3g를 설치할 수 없다. 이 RHEL과 CentOS는 서버에 특화된 리눅스라고 할 수 있다. 사실 본인도 리눅스 서버에서 NTFS를 특별히 지원할 필요는 없다고 생각된다.

이 논쟁이 될 수 있는 소지는 뒤로하고 NTFS를 마운트 할 수 있는 환경을 만들어보자.


  1. Repository에 RPMForge 등록하기 
    RPMForge Repository는 일반적인 /etc/yum.repos.d/ 에 추가하는 방식이 아닌 RPM을 통하여 등록하도록 하고 있다.

    다운로드 URL은 다음과 같다.

    자신의 architecture에 해당하는 파일을 다운로드를 받은 후 rpm 명령을 통하여 설치한다. 다운로드 파일 검증이라는 과정이 있지만 이 부분은 생략한다. 자세한 사항은 위에서 언급한 URL에서 확인한다.


  2. ntfs-3g 패키지 설치하기이제 yum을 통하여 ntfs-3g 패키지를 설치할 수 있을 것이다.

    # yum install fuse fuse-ntfs-3g
  3. NTFS 마운트 하기
    마운트는 별반 다른게 없으며 단지 fstype을 ntfs-3g로 하면 된다. 

Thursday 13 January 2011

SSH Brute forcing 방지 방화벽 정책 2

    • Here I will show you how to add the first rule in iptables...
    • The 1st rule we add is where we tell iptables to create a list called ssh_attempt and store the source ip of every recent ssh attempt on port 22 using tcp on interface eth0.
    • "iptables -A INPUT -i eth0 -p tcp -m tcp --dport 22 -m state --state NEW -m recent --set --name ssh_attempt --rsource"
    • step by step explanation..
    • iptables is the command that you use to enter the firewall rules in.
    • "-A INPUT" means APPEND to the INPUT chain
    • "-i eth0" means this rule will use the interface eth0
    • "-p tcp" means we are using the TCP protocol
    • "-m tcp" means we are matching the TCP protocol
    • "--dport 22" means we are matching based on the destination port 22
    • "-m state --state NEW" This rule will only apply to NEW incoming ssh connections not ESTABLISHED or RELATED.
    • "-m recent --set --name ssh_attempt --rsource" allows us to match packets based on recent events that we have previously matched and sets the name of the list , while saving the source ip address and port.
    • In this step we will show you how to deny those bots..
    • "iptables -A INPUT -i eth0 -p tcp -m tcp --dport 22 -m state --state NEW -m recent --update --seconds 10 --hitcount 2 --name ssh_attempt --rsource -j DROP"
    • The only difference in this rule is these options.
    • "--update --seconds 10 --hitcount 1 --name ssh_attempt" This will match true if the source is available in the specified list and it also updates the last-seen time in the list. The "--seconds 10" match is used to specify how long since the "last seen". The "--hitcount 2" will limit the match to only include packets that have seen at least the hitcount amount of packets.

Screen HowTo Part 2

Linux HowTo's - Advance Linux HowTo's
Written by Allen Sanabria   
Saturday, 17 May 2008 10:39

In the the first part of this HowTo,  I gave you the bare minimum to get Screen working
and how to use it on a day to day basis.... This time around I will show you some
of the advanced features of screen that may make your life easier in the terminal..
Before continuing this HowTo please read Part 1 if you do not have previous experience with screen.
So lets start this HowTo with some more Screen Commands...

 







1- To start a split screen session in you current screen session...
    ((ctrl+a) S
2- To switch between split screens...    ((ctrl+a) )...
3- To copy output from one split screen to the next...
    ((ctrl+a) [) now using the up and down arrow find the output you want to copy and from where you want to start copying hit the and keep using the arrows to where you want to stop copying and hit the  again.
4- To paste the output from the previous command...
    ((ctrl+a) ]) Now if you want to paste it in the split terminal you would have to do step 2 then step 4.
I use the above commands especially to copy output from one terminal to next without a mouse.
5- Now lets say you want to lock our screen session from private eyes...
   ((ctrl+ax)   
To unlock your session just use your password for you account.
The following below will make your screen session show all of your sessions in a nice bar below your terminal, show you the current date and time, as well as tell you the host you are in. Check the screenshot above to see what it would look like.

Add the following below to .screenrc in your home directory..... Example /home/dynasty/.screenrc
hardstatus alwayslastline 
hardstatus string '%{b}[ %{B}%H %{g}][%= %{wk}%?%-Lw%?%{=b kR}
(%{W}%n*%f %t%?(%u)%?%{=b kR})%{= kw}%?%+Lw%?%?%= %{g}][%{Y}%l%{g}]%{=b C}[ %m/%d %c ]%{W}'
startup_message off
defscrollback 200000
shelltitle dynasty
caption always

Screen HowTo Part 1

Linux HowTo's - Advance Linux HowTo's
Written by Allen Sanabria   
Sunday, 11 May 2008 17:46

I've been using screen for the past 3 years and for the first time I've decided to seek out more functionality out of it.  So last week I spent about 2 hours looking up some of the different functionality that I can use in the day to day. Let me tell you I found a bunch of goodies that I use now religiously (For a week now ;) ).
So for those of you who do not know what a screen session is... (STRAIGHT FROM THE MAN PAGES) Screen is a full-screen window manager that multiplexes a physical terminal between several processes (typically interactive shells).  Essentially you can have 30 terminal sessions inside one terminal and much more.....
 To run Screen all you need to do is type "screen" in your terminal. You more then likely do not have it installed by default. So for those of you who have the distributions below... 
  1. Fedora/CentOS/RHE/ or any RedHat based system, you will need to run "yum install screen"
  2. Ubuntu/Debian based systems, you will need to run "apt-get install screen"
  3. Gentoo based systems, you will need to run "emerge screen"

To start a new screen session all you have to do is type "screen"
Now that you are in a screen session, the fun begins now...







1- To start a new sub session (Virtual Session) type
   ((ctrl+a) c)
  Please ignore the plus (+)symbol, this essentially means "ctrl a then c"
2- To switch between sessions...
   ((ctrl+a) )

3- To switch between your previous session and the current one..
   ((ctrl+a) a)
4- To kill a frozen session...
   ((ctrl+a) k
5- To see a list of available commands...
   ((ctrl+a) ?)
6- To see a list of virtual terminals you have open..
   ((ctrl+a) ")
7- To Detach from a screen session and not lose any of your virtual terminals...
   ((ctrl+a) d)( This is one of the best features of screen!! )
8- To view  current screen sessions once you are logged out of screen..
   "screen -list"

9- To reattach to an Attached session (Session that was not detached properly)
   "screen -D -r <11546.pts-5.hostname>" (session name from the output of the screen -list command)

10- To reattach to a detached session..
   "screen -r <11546.pts-5.hostname>" (session name from the output of the screen -list command)

10- To end that session you can either type
  "exit" or a (ctrl+d)

Monday 10 January 2011

RHEL 에서 nc(netcat)을 이용하여 간단한원격백업


1. 원본서버에서 (/opt 파티션을 tar 로 묶어서 원격서버에 백업하는예) 
# tar cvfz - /opt | nc -l -p 8888 -c
  →  /opt 백업디렉토리
  → -p 8888  포트번호 (/etc/service 에 정의되지않은 포트번호 아무거나)
  → -c 출력이 끝나면 커넥션 자동 close

2. 받는서버
 # nc 10.1.1.100 8888 > opt.tar.gz
 → 10.1.1.100 원본서버 아이피