공부방
search

초보공부
혼자 공부하고 메모하고
Today
Yesterday
0218 - VMware tools, ssh 보안, LVM, FTP
Network Access = A - B = 타 개체에 접근
커플링 = Key
IKE(Internet Key Exchange) = 전 세계 우리둘만 아는 걸 맹글자~라는 개념입니다.
1. PSK(Preshared-Key) = 접속 전에 미리 공유한 대칭 키 = WiFi에서 암호화 및 무결성 한번쯤 보셨을 꺼에요
A --- B
1234 1234
2. RSA = 비대칭 키
공개키=부호화 1234 -> $6123abc $6asdfiasjodfajsfasfj1231241824u
개인키=복호화 $6123abc -> 1234 => $6asdfiasjodfajsfasfj1231241824u
===============================================================================================================
37 번행
#LogLevel INFO 로그기록 수준을 의미하는 항목
emerg : 시스템이 다운되는 수준
crit : 유틸리티나 서브시스템을 종료해야 하는 수준
warning : 단순 경고 메시지 수준
info : 정보를 보여줘야 하는 수준
39번행
#Authentication : 인증 (ID 식별 인증 항목)
42번행
#PermitRootLogin yes : 관리자로의 로그인을 허용 할것인가에
대한 항목
기본값으로 관리자의 접근을 허용하지만
권장하진 않는다
----------------------------------
** ssh 보안설정
usermod -G wheel user1
find / -name su
/bin/su ==> su 변경
ls -l /bin/su
chown .wheel /bin/su
chmod 4750 /bin/su
------------------------------------
47번행 : RSA 인증 옵션, 프로토콜 버전1에서만 적용되는 옵션
65번행 : Password 없이 접속 여부 // 기본값 NO
PAM : 착탈형 인증묘듈 = 지정된 서비스에 인증에 대한
묘듈화 지원
126번행 : 가상 root 디렉토리 지원
132번행 : sshd 데몬을 통하여 다른 프로그램
즉, sftp-server를 실행할 수 있도록 설정하는 항목
==========================================================
** SSH 서비스 접속
sftp 라는 건 SSH 를 설치 하게 되면 자동으로 sftp 를 쓸수 있게 된다
그냥 ssh로 ftp를 사용 = 보안화된 ftp정도로 생각하면 됨.
sftp 192.168.1.10 : ssh 서비스 접속
ssh 192.168.1.10 : 로그인 한 계정으로 접속 시도
ssh user1@서버IP : 지정한 계정으로 접속시도
sftp user1@서버IP : /home ==> home 디렉토리로 접속
==========================================================
원격지의 데이터 복사하기 : scp(secure Copy)
ssh 서비스가 구성되어 있는 System을 대상으로 원격 복사 할 수 있는 프로그램이며
openssh-clients" 패키지에 포함 되어 있다
#scp [Option] [원본파일 위치] [Server-IP] => 접속한 계정으로 보안복사 시도
#scp [Option] [원본파일 위치] [계정명]@[Server-IP] => 지정한 계정명으로 보안 복사 시도
======================================================================================
문제~)
192.168.1.10 = Server IP
192.168.1.20 = Client IP
Server Client
/test/1 /iu/11
/test/2 /iu/22
/test/3 /iu/33
#scp 192.168.1.10:/test/1 /iu/ 다운로드 (클라이언트 중심)
#scp /iu/11 192.168.1.10:/test/ 업로드 (서버 중심)
※cp 옵션이랑 똑같다 = 디렉토리 복사시 -r 옵션 !!!
sftp username@ip
=> 원격서버 접속
들어가면 working directory로 접속된다
put ??
=> ?? 파일을 서버에 업로드
chown :?? /aaa
aaa디렉토리의 그룹 소유권을 ??로 바꾼다
서버 설정
1.서버 종료 후 1G 새로운 DISK 추가 후 부팅
2. 새 DISK를 fdisk라는 명령어로 파티션 쪼개기
1p 200m
2p 500m
3ex etc(남은용량 모두)
5L etc(남은용량 모두)
3. mkfs -t ext4 /dev/sdb2 명령어 적으셔서 포맷
4. mkdir -p /ssh/sdb 명령어 적으셔서 mp를 생성
5. vi /etc/fstab 들어가서 자동 마운트까지 진행
/dev/sdb2 /ssh/sdb ext4 defaults 1 2 <= 이렇게 입력하고 나와서 mount -a 까지 (오타 검증)
6. cd /ssh/sdb 들어가서
7.mkdir scp sftp ssh && touch scp/chw sftp/user1 ssh/iu 디렉토리와 각각 하위에 있는 파일들까지 생성
8. vi /etc/ssh/sshd_config 가서 42번줄에 root의 로그인은 불가
9. ls -l /bin/su 해서 SetUID 셋팅 => iu 라는 계정만 su 명령어 이용 가능 (wheel 그룹에 iu 계정을 추가해 주세요)
클라이언트 설정
1. mkdir /client
2. cd /client
3.mkdir scp sftp ssh && touch scp/chw_lucky sftp/user1_lucky ssh/iu_lucky
서버의 디렉토리 및 파일 생성 현황
/ssh/sdb/scp/chw(file)
/ssh/sdb/sftp/user1(file)
/ssh/sdb/ssh/iu(file)
client의 디렉토리 및 파일 생성 현황
/client/sdb/scp/chw_lucky(file)
/client/sdb/sftp/user1_lucky(file)
/client/sdb/ssh/iu_lucky(file)
문제 푸는 방법
1. 서버 putty 종료, 모든 실행은 client putty에서 진행
2. /client 하위에 있는 디렉토리들 방법으로 업/다운을 합니다.
3. server에 있는 각 scp,sftp,ssh 디렉토리 밑에 있는 파일들을 클라이언트로 같은 이름의 디렉토리로 다운로드
4. /client 하위의 디렉토리 밑에 있는 각각의 파일 들을 서버로 같은 이름의 디렉토리로 업로드
/ssh/sdb/scp/chw(file) <-> /client/scp/chw_lucky chw계정으로 up/down (uid 권한 수정)
/ssh/sdb/sftp/user1(file) <-> /client/sftp/user1_lucky sftp 방법으로 user1 계정으로 up/down(gid 권한 수정)
/ssh/sdb/ssh/iu(file) <-> /client/ssh/iu_lucky scp,sftp 아무거나 iu계정으로 up/down(권한수정x)
login as: root
root@192.168.1.20's password:
Last login: Tue Feb 18 10:23:32 2025 from 192.168.1.1
[root@centos6 ~]# [root@centos6 ~]#
-bash: [root@centos6: command not found
[root@centos6 ~]# clear
[root@centos6 ~]# scp chw@192.168.1.10:/ssh/sdb/scp/chw /client/scp
chw@192.168.1.10's password:
chw 100% 0 0.0KB/s 00:00
[root@centos6 ~]# ls -lR
.:
합계 100
-rw-------. 1 root root 1567 2025-02-11 19:14 anaconda-ks.cfg
-rw-r--r--. 1 root root 46676 2025-02-11 19:14 install.log
-rw-r--r--. 1 root root 10225 2025-02-11 19:12 install.log.syslog
drwxr-xr-x. 2 root root 4096 2025-02-11 19:22 공개
drwxr-xr-x. 2 root root 4096 2025-02-11 19:22 다운로드
drwxr-xr-x. 2 root root 4096 2025-02-11 19:22 문서
drwxr-xr-x. 2 root root 4096 2025-02-11 19:22 바탕화면
drwxr-xr-x. 2 root root 4096 2025-02-11 19:22 비디오
drwxr-xr-x. 2 root root 4096 2025-02-11 19:22 사진
drwxr-xr-x. 2 root root 4096 2025-02-11 19:22 음악
drwxr-xr-x. 2 root root 4096 2025-02-11 19:22 템플릿
./공개:
합계 0
./다운로드:
합계 0
./문서:
합계 0
./바탕화면:
합계 0
./비디오:
합계 0
./사진:
합계 0
./음악:
합계 0
./템플릿:
합계 0
[root@centos6 ~]#
[root@centos6 ~]# clear
[root@centos6 ~]# cd /client
[root@centos6 client]# ls -lR
.:
합계 12
drwxr-xr-x. 2 root root 4096 2025-02-18 14:49 scp
drwxr-xr-x. 2 root root 4096 2025-02-18 13:54 sftp
drwxr-xr-x. 2 root root 4096 2025-02-18 13:54 ssh
./scp:
합계 0
-rw-r--r--. 1 root root 0 2025-02-18 14:49 chw
-rw-r--r--. 1 root root 0 2025-02-18 13:54 chw_lucky
./sftp:
합계 0
-rw-r--r--. 1 root root 0 2025-02-18 13:54 user1_lucky
./ssh:
합계 0
-rw-r--r--. 1 root root 0 2025-02-18 13:54 iu_lucky
[root@centos6 client]# clear
[root@centos6 client]# sftp user1@192.168.1.40
Connecting to 192.168.1.40...
1
ssh: connect to host 192.168.1.40 port 22: No route to host
Couldn't read packet: Connection reset by peer
[root@centos6 client]# 1
-bash: 1: command not found
[root@centos6 client]# clear
[root@centos6 client]# sftp user1@192.168.1.40
Connecting to 192.168.1.40...
ssh: connect to host 192.168.1.40 port 22: No route to host
Couldn't read packet: Connection reset by peer
[root@centos6 client]# ^C
[root@centos6 client]# sftp user1@192.168.1.10
Connecting to 192.168.1.10...
user1@192.168.1.10's password:
sftp> pwd
Remote working directory: /home/user1
sftp> cd /ssh/sdb/sftp
sftp> pwd
Remote working directory: /ssh/sdb/sftp
sftp> ls -l
-rw-r--r-- 1 root root 0 Feb 18 13:51 user1
sftp> lpwd
Local working directory: /client
sftp> lcd /client/sftp
sftp> get user1
Fetching /ssh/sdb/sftp/user1 to user1
sftp> exit
[root@centos6 client]# ls -lR
.:
합계 12
drwxr-xr-x. 2 root root 4096 2025-02-18 14:49 scp
drwxr-xr-x. 2 root root 4096 2025-02-18 14:50 sftp
drwxr-xr-x. 2 root root 4096 2025-02-18 13:54 ssh
./scp:
합계 0
-rw-r--r--. 1 root root 0 2025-02-18 14:49 chw
-rw-r--r--. 1 root root 0 2025-02-18 13:54 chw_lucky
./sftp:
합계 0
-rw-r--r--. 1 root root 0 2025-02-18 14:50 user1
-rw-r--r--. 1 root root 0 2025-02-18 13:54 user1_lucky
./ssh:
합계 0
-rw-r--r--. 1 root root 0 2025-02-18 13:54 iu_lucky
[root@centos6 client]# scp iu@192.168.1.10:/ssh/sdb/ssh/iu /client/ssh
iu@192.168.1.10's password:
iu 100% 0 0.0KB/s 00:00
[root@centos6 client]# ls -lR
.:
합계 12
drwxr-xr-x. 2 root root 4096 2025-02-18 14:49 scp
drwxr-xr-x. 2 root root 4096 2025-02-18 14:50 sftp
drwxr-xr-x. 2 root root 4096 2025-02-18 14:51 ssh
./scp:
합계 0
-rw-r--r--. 1 root root 0 2025-02-18 14:49 chw
-rw-r--r--. 1 root root 0 2025-02-18 13:54 chw_lucky
./sftp:
합계 0
-rw-r--r--. 1 root root 0 2025-02-18 14:50 user1
-rw-r--r--. 1 root root 0 2025-02-18 13:54 user1_lucky
./ssh:
합계 0
-rw-r--r--. 1 root root 0 2025-02-18 14:51 iu
-rw-r--r--. 1 root root 0 2025-02-18 13:54 iu_lucky
[root@centos6 client]# clear
[root@centos6 client]# scp /client/scp/chw_lucky chw@192.168.1.10:/ssh/sdb/scp
chw@192.168.1.10's password:
scp: /ssh/sdb/scp/chw_lucky: Permission denied
[root@centos6 client]# clear
[root@centos6 client]# ssh iu@192.168.1.10
iu@192.168.1.10's password:
Last login: Tue Feb 18 12:21:52 2025 from 192.168.1.20
[iu@centos6 ~]$ whoami
iu
[iu@centos6 ~]$ chown
chown: missing operand
더 많은 정보를 보려면 `chown --help' 하십시오.
[iu@centos6 ~]$ clear
[iu@centos6 ~]$ su
암호:
[root@centos6 iu]# whoami
root
[root@centos6 iu]# cd /ssh/sdb
[root@centos6 sdb]# ll
합계 18
drwx------. 2 root root 12288 2025-02-18 13:50 lost+found
drwxr-xr-x. 2 root root 1024 2025-02-18 13:51 scp
drwxr-xr-x. 2 root root 1024 2025-02-18 13:51 sftp
drwxr-xr-x. 2 root root 1024 2025-02-18 13:51 ssh
[root@centos6 sdb]# chown chw scp
[root@centos6 sdb]# chown :user1 sftp
[root@centos6 sdb]# chmod 775 sftp/
[root@centos6 sdb]# ll
합계 18
drwx------. 2 root root 12288 2025-02-18 13:50 lost+found
drwxr-xr-x. 2 chw root 1024 2025-02-18 13:51 scp
drwxrwxr-x. 2 root user1 1024 2025-02-18 13:51 sftp
drwxr-xr-x. 2 root root 1024 2025-02-18 13:51 ssh
[root@centos6 sdb]# exit
exit
[iu@centos6 ~]$ clear
[iu@centos6 ~]$ exit
logout
Connection to 192.168.1.10 closed.
[root@centos6 client]# ifconfig eth0 |grep 192
inet addr:192.168.1.20 Bcast:192.168.1.255 Mask:255.255.255.0
[root@centos6 client]# scp /client/scp/chw_lucky chw@192.168.1.10:/ssh/sdb/scp
chw@192.168.1.10's password:
chw_lucky 100% 0 0.0KB/s 00:00
[root@centos6 client]# sftp user1@192.168.1.10
Connecting to 192.168.1.10...
user1@192.168.1.10's password:
sftp> cd /ssh/sdb/sftp
sftp> pwd
Remote working directory: /ssh/sdb/sftp
sftp> ls -l
-rw-r--r-- 1 root root 0 Feb 18 13:51 user1
sftp> lcd /client/sftp
sftp> put user1_lucky
Uploading user1_lucky to /ssh/sdb/sftp/user1_lucky
user1_lucky 100% 0 0.0KB/s 00:00
sftp> ls -l
-rw-r--r-- 1 root root 0 Feb 18 13:51 user1
-rw-r--r-- 1 user1 user1 0 Feb 18 14:54 user1_lucky
sftp> cd ../scp
sftp> ls -l
-rw-r--r-- 1 root root 0 Feb 18 13:51 chw
-rw-r--r-- 1 chw chw 0 Feb 18 14:53 chw_lucky
sftp> exit
[root@centos6 client]# clear
[root@centos6 client]# ssh iu@192.168.1.10
iu@192.168.1.10's password:
Last login: Tue Feb 18 14:52:20 2025 from 192.168.1.20
[iu@centos6 ~]$ ifconfig eth0 |grep 192
inet addr:192.168.1.10 Bcast:192.168.1.255 Mask:255.255.255.0
[iu@centos6 ~]$ su
암호:
[root@centos6 iu]# scp 192.168.1.20:/client/ssh/iu_lucky /ssh/sdb/ssh
The authenticity of host '192.168.1.20 (192.168.1.20)' can't be established.
RSA key fingerprint is a6:54:bc:66:a1:dd:ab:25:71:f6:b3:1d:da:bd:8c:cd.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '192.168.1.20' (RSA) to the list of known hosts.
root@192.168.1.20's password:
iu_lucky 100% 0 0.0KB/s 00:00
[root@centos6 iu]# cd /ssh/sdb
[root@centos6 sdb]# ls -lR
.:
합계 18
drwx------. 2 root root 12288 2025-02-18 13:50 lost+found
drwxr-xr-x. 2 chw root 1024 2025-02-18 14:53 scp
drwxrwxr-x. 2 root user1 1024 2025-02-18 14:54 sftp
drwxr-xr-x. 2 root root 1024 2025-02-18 14:56 ssh
./lost+found:
합계 0
./scp:
합계 2
-rw-r--r--. 1 root root 0 2025-02-18 13:51 chw
-rw-r--r--. 1 chw chw 0 2025-02-18 14:53 chw_lucky
./sftp:
합계 2
-rw-r--r--. 1 root root 0 2025-02-18 13:51 user1
-rw-r--r--. 1 user1 user1 0 2025-02-18 14:54 user1_lucky
./ssh:
합계 2
-rw-r--r--. 1 root root 0 2025-02-18 13:51 iu
-rw-r--r--. 1 root root 0 2025-02-18 14:56 iu_lucky
[root@centos6 sdb]# exit
exit
[iu@centos6 ~]$ exit
logout
Connection to 192.168.1.10 closed.
[root@centos6 client]# ls -lR
.:
합계 12
drwxr-xr-x. 2 root root 4096 2025-02-18 14:49 scp
drwxr-xr-x. 2 root root 4096 2025-02-18 14:50 sftp
drwxr-xr-x. 2 root root 4096 2025-02-18 14:51 ssh
./scp:
합계 0
-rw-r--r--. 1 root root 0 2025-02-18 14:49 chw
-rw-r--r--. 1 root root 0 2025-02-18 13:54 chw_lucky
./sftp:
합계 0
-rw-r--r--. 1 root root 0 2025-02-18 14:50 user1
-rw-r--r--. 1 root root 0 2025-02-18 13:54 user1_lucky
./ssh:
합계 0
-rw-r--r--. 1 root root 0 2025-02-18 14:51 iu
-rw-r--r--. 1 root root 0 2025-02-18 13:54 iu_lucky
LVM
1g 3개 10g 3개 추가
RAID 생성
레이드 생성된게 확인됨
RAID(Rendundancy Array Inexpensive Disk)
=물리적 다중 디스크를 모아서 논리적 단일 디스크로 만드는것
장점 : 속도 자동복구
단점 : array 축소 확장 불가능
===============================================================================================
LVM(Logical Volume Management)
=물리적 다중 디스크를 모아서 하나의 볼륨 그룹으로 만든 다음 다시 논리적 볼륨으로 쪼갠다 = 뷔페
P.V V.G:LVM_VG L.V
장점 : 볼륨 축소 및 확장이 탄력적이다 => 레이드의 단점복구
단점 : 속도증가 및 자동복구 안됨
LVM 구성순서 = PV -> VG -> LV
PV 물리적 볼륨 정의
VG 뭉친다
LV 다시 쪼갠다
**명령어
create 생성
remove 삭제
scan 검색 = 심플하게 보는거
display 확인 = 자세히
extend 확장
reduce 축소
change 속성변경 -a y/n 사용여부 -l 숫자 logical 볼륨수
pv생성
vg 생성
축소
추가
탄력적 축소/확장이 용이하기 때문에 직접보다는 링크로써 간접사용하는 특징을 가진다
가져간만큼 빠짐
-l : 퍼센트로 할경우 (소문자)
-L : 정확한 용량으로 할경우 (대문자)
용량을 빼서 바로넣을순 없음
용량을 빼면 프리공간으로 가는데 그걸 다른곳에 주는것
용량빼기
프리영역이 12로 증가됨
12가 빠짐
추가해주면
프리영역에 있던 용량이 사라짐
라벨링 : 이름이 너무 길어서 줄인다
라벨링 하기전에 포맷부터
포맷
tune2fs => 라벨링할 이름이 앞으로옴
e2label => 라벨링할 이름이 뒤로감
e2label은 이런식으로 셋팅하는 명령어로도 쓰이지만 확인하는 명령어로도 쓰인다
마운트포인트로 사용할 디렉토리를 만들고 마운트 포인트안에는 비어있는게 확인됨
ye한단어복사
jp붙여넣기
LVM1을 LVM2로 바꿔줌
ftp
만약 vsftpd가 안깔려있다면
이렇게 선택하면
centos가 연결되고
패키지로 들어가서 vsftpd패키지를 찾아서 install하면된다
데몬을 up하면 포트가 열리고 down하면 포트가 닫힌다
selinux (보안정책) 설정
설정을 바꿔도
enforcing모드인데
이때는 init 6해서 재부팅하면된다
처음엔 안뜨는데
gui환경에서 로그인하니까 sr0가 나온다
재부팅해서 데몬이 꺼짐
space로 체크하고 확인
재부팅하고나면 이제 자동으로 켜질거임
재부팅하고 자동으로 켜지는게 보임
ftp체크
종료하면
cmd로 들어가진다
익명계정으로 비밀번호는 없음
여기 나오는 pub가
이 pub임