- 2024.05.07.화.보안 day242024년 05월 07일 10시 23분 18초에 업로드 된 글입니다.작성자: 202401to07
오늘은 ssh~
tail -f /var/log/secure : ssh 로그인 정보
tail -f /var/log/messages : ssh 로그인 정보 ---> 모든 전체적인 로그
wheel 관리자 권한
https://www.kisa.or.kr/2060204/form?postSeq=12&lang_type=KO&page=1
KISA 한국인터넷진흥원
www.kisa.or.kr
원격접속보안관련
telnet 설치
yum install telnet
yum install telnet-server
rpm -qa |grep telnet
rpm -ql telnet-server
service telnet.socket restart
netstat -lntup
firewall-cmd --permanent --add-port 23/tcp
firewall-cmd --reload
firewall-cmd --list-all/var/run/utmp 접속중인 사용자 (w,users,who)
/var/log/wtmp 접속한 사용자 (last)
/var/log/btmp 접속실패 사용자 (lastb)sftp sevas@10.10.10.10:\server
put 주기
get 가져오기
클라이언트에서 서버로 공개키 보내는 방법
클라이언트에서 서버로 공개키 보내는 방법
클라이언트 :
[root@sevas10 client]# ssh-keygen -t rsa -> 공개 및 개인 키 쌍을 생성
( 기본적으로 id_rsa : 개인 키 , id_rsa.pub : 공개 키 )
[root@sevas10 .ssh]# ll
합계 12
-rw------- 1 root root 2602 5월 7 12:55 id_rsa -> 이게 개인 키
-rw-r--r-- 1 root root 566 5월 7 12:55 id_rsa.pub -> 이게 공개키
-rw-r--r-- 1 root root 173 5월 7 11:19 known_hosts
[root@sevas10 .ssh]# scp id_rsa.pub 10.10.10.10:/root/.ssh -> 공개키를 10.10.10.10의 root의 해당경로로 복사하기scp id_rsa.pub 10.10.10.10:/root/.ssh = scp id_rsa.pub root@10.10.10.10:/root/.ssh
root@10.10.10.10's password:
id_rsa.pub 100% 566 720.4KB/s 00:00
서버 :
[root@localhost home]# cd /root/.ssh/ -> 해당 위치에 (일반적으로는 /home/(계정)/.ssh 인데 root는 /root/.ssh)
[root@localhost .ssh]# ll
합계 8
-rw-r--r-- 1 root root 566 5월 7 12:59 id_rsa.pub -> 공개키가 들어온것을 확인할수있다
-rw-r--r-- 1 root root 173 5월 7 11:19 known_hosts서버 설정 :
[root@localhost .ssh]# vi /etc/ssh/sshd_config
#PubkeyAuthentication yes
PubkeyAuthentication yes
ㄴ public키 인증 사용옵션 yes
#AuthorizedKeysFile .ssh/authorized_keys
AuthorizedKeysFile .ssh/id_rsa.pub
ㄴ 권한 키 파일을 클라이언트의 공개키로 바꾸기
#PasswordAuthentication yes
PasswordAuthentication no
ㄴ인증여부 사용 안함 / 다른 계정자체를 못쓰게 함
결과 :
[root@sevas10 .ssh]# ssh sevas@10.10.10.10 - >공개키 없는 sevas로 접속하려자
sevas@10.10.10.10: Permission denied (publickey,gssapi-keyex,gssapi-with-mic). -> 거부당한다
[root@sevas10 .ssh]# ssh root@10.10.10.10 -> 공개키를 준 root로 로그인은
Last login: Tue May 7 13:29:17 2024 from 10.10.10.20 -> 성공한다공개키 개인키는 *계정별*인것을 잊지마라
로컬 터널링
원격 터널링
ㄴ 다시 해봐 나 실패함
PasswordAuthentication yes -> yes가 기본값
#PasswordAuthentication noㄴ 원격 터널링
10.10.10.10 22번으로 1004 포트를 만들면
ㄴ터널을 들어가고
ㄴ10.10.10.10 들어가면
나중에 10.10.10.10을 끄면 터널10.10.10.10도 꺼진다
로컬 터널링 :
[root@localhost ~]# firewall-cmd --list-all
public (active)
target: default
icmp-block-inversion: no
interfaces: ens33
sources:
services: dhcpv6-client ssh
ports: 23/tcp 4000-4005/tcp
protocols:
masquerade: no
forward-ports:
source-ports:
icmp-blocks:
rich rules:
[root@localhost ~]# cat /etc/ssh/sshd_config
#AllowTcpForwarding yes
AllowTcpForwarding yes
#GatewayPorts no
GatewayPorts yes
#PermitTunnel no
PermitTunnel yes결과 :
x11 포워딩
vi /etc/ssh/sshd_conf
X11Forwarding yes
X11DisplayOffset 10
X11UseLocalhost yes
cd /root
touch .Xauthority
chmod 660 .Xauthority
service sshd restart
윈도우에서
Xming설치Xming-6-9-0-31-setup.exe2.10MB
putty => ssh => x11 => enable X11 forwarding 체크
접속후 gedit실행
yum install xclockyum install gedit
X윈도
실습 말고 설명만
로컬 첫번째 서버 두번째는 모니터데스크탑은 환경 인터페이스디스플레이는 권한 아이디 계정xhost는 + -xauth 는 .Xauthority'보안' 카테고리의 다른 글
2024.05.09.목.보안 day26 (0) 2024.05.09 2024.05.08.수.보안 day25 (0) 2024.05.08 5/7 시험 대비-100점 (0) 2024.05.04 2024.05.03.금.보안 day23 (0) 2024.05.03 2024.05.02.목.보안 day22 (0) 2024.05.02 다음글이 없습니다.이전글이 없습니다.댓글