5/09/2012
ubuntu ssh server setting
* ssh 서버 설치 및 설정
http://wiki.kldp.org/wiki.php/DocbookSgml/SSH-KLDP
1. 설치
$ sudo apt-get install ssh
2. 포트 변경
$ sudo vim /etc/ssh/sshd_config
# port 22 에서 '#' 를 제거하고 원하는 포트로 변경
IF >> X-window 사용하고 싶을 경우,
/etc/ssh/ssh_config
위의 파일의 다음내용을 변경한다
# ForwardX11 no -> ForwardX11 yes 로 설정변경)
3. 데몬 재시작
$ sudo /etc/init.d/ssh restart
4. 서버 작동 확인
$ netstat -ntl
ref: http://towanouta.tistory.com/71
2/18/2011
samba IP allow setting
$ sudo vi /etc/samba/smb.conf
in [global] section, add this line
hosts allow = 192.168.0.11 192.168.0.12
$ sudo service smbd restart
11/15/2010
django + apache server 1
cat /etc/apache2/httpd.conf
(location "/")
SetHandler python-program
PythonHandler django.core.handlers.modpython
PythonPath "['[path.to.django.project]', '[path.to.other.location.which.has.python.code]'] + sys.path"
SetEnv DJANGO_SETTINGS_MODULE [projectName].settings
PythonDebug On
(/location)
where, "(" and ")" should be replaced with "<" and ">"
In web browser, http://localhost/ gives the "It worked" page of django.
If "import error" occur, check the [path.to.directory] point out the right directory which contains the module.
2. utf-8 setting
$ cat /etc/apache2/envvars
...
export LANG=ko_KR.UTF-8
export LC_ALL=ko_KR.UTF-8
...
$ /etc/init.d/apache2 restart
3. Running a development server with apache mod_python
If a django python code was changed, apache server must be restarted.
To avoid this, just set
MaxRequestsPerChild 1
in /etc/apache2/apache2.conf
This force apache to reload everything for each request.
When debugging, use the code below to display a debugging information.
assert False, 'debug text'
4. Make database (mysql)
5. Make project, app
django-admin startproject (aaa)
cd aaa
./manage.py startapp (bbb)
in settings.py
add the code below
import os
ROOT_PATH = os.path.dirname(__file__)
add to TEMPLATE_DIRS
ROOT_PATH + '/templates',
and in INSTALLED_APPS, add
'aaa.bbb',
change the LANGUAGE_CODE option like
LANGUAGE_CODE = 'ko-KR'
and setting DB infomation.
DATABASE_ENGINE = 'mysql' # 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'.
DATABASE_NAME = 'dbname' # Or path to database file if using sqlite3.
DATABASE_USER = 'userid' # Not used with sqlite3.
DATABASE_PASSWORD = 'password' # Not used with sqlite3.
DATABASE_HOST = '' # Set to empty string for localhost. Not used with sqlite3.
DATABASE_PORT = '' # Set to empty string for default. Not used with sqlite3.
6. sync db
manage.py syncdb
Here, set user name and password.
7.
5/19/2010
scanning port state whether opened, closed or filtered by using nmap
[root@localhost ~]# nmap -sT -p 1-65535 localhostref: http://kldp.org/node/91134
Starting Nmap 4.11 ( http://www.insecure.org/nmap/ ) at 2008-02-19 01:47 KST
Interesting ports on xxx.xxx.xxx.xxx:
Not shown: 65531 closed ports
PORT STATE SERVICE
22/tcp open ssh
80/tcp open http
111/tcp open rpcbind
645/tcp open unknown
Nmap finished: 1 IP address (1 host up) scanned in 2.391 seconds
7/11/2009
Simple web server using python
cd /folder/to/be/used/as/web/root/
sudo python -m SimpleHTTPServer 8888
where, 8888 is port number.
4/06/2009
DDoS attacks..
1. TCP Syn flood attack : send syn and dont reply act
2. Send no data after handshake
3. Get data very slowly(about 1 byte/sec) after handshake.
1/17/2009
apache 웹서버에서 .htaccess 설정
http://open.asianux.co.kr/mapping.php?bbsId=TIPNTECH&action=View&doc_number=39&pageNo=4
| 웹서버 접속제한? |
| 서 말했듯이 특정 페이지에 인증을 걸어두어 지정된 사용자가 아닌 경우 웹페이지를 보여주지 않도록 설정하는 것을 말하는 것으로, Apache와 같은 웹서버에서는 .htaccess 라는 파일을 생성하여 설정할 수 있다.
========================== |
| ① .htaccess 파일 생성 |
| 먼저 .htaccess 파일을 생성하도록 하자. 인증이 필요한 디렉터리로 이동하여 touch 명령을 통해 파일을 만든다. |
| ② .htaccess 파일 설정 |
| 앞서 생성한 파일은 아무런 내용이 없는 빈 파일이므로 아래와 같은 내용을 입력하자.
- AuthName는 암호 인증창에 나타나는 설명을 적는 곳이다. 이곳에 적은 내용이 인증창에 문구로 나오게 된다.
※ satisfy는 all과 any를 지시자로 가질 수 있으며, 각 의미는 아래와 같다.
위는 지시어를 모두 사용하였을 경우에 대한 예제로서, 아래와 같이 간단하게 만들수도 있다.
|
| ③ 사용자 및 패스워드 등록 |
| .htaccess 설정이 완료되었다면, htpasswd 명령을 이용하여 해당 디렉터리로 접근 가능한 사용자 계정 및 패스워드를 생성한다. 아래 예제는 admin 이라는 계정을 추가하는 내용으로 패스워드를 지정하는 부분까지 같이 이루어진다. # htpasswd -c .htpasswd admin ===================================================== ※ -c 옵션은 초기화 후 새롭게 생성할때 이용하는 옵션이다. |
| ④ 웹서버 재시작 |
자 이제 설정 및 사용자 등록이 완료되었으므로, 아래와 같은 명령으로 웹서버를 재시작하자.
# /etc/init.d/httpd restart
만약 소스설치를 한 경우라면, apache가 설치되어 있는 경로로 이동하여 bin 디렉터리 하단에 있는 apachectl 실행명령을 stop 및 start 하자.
이제 웹브라우저를 사용하여 admin 디렉터리 하단에 있는 웹페이지를 열어보도록 하자. 사용자 인증창이 정상적으로 나타나는가?