๋ณธ๋ฌธ ๋ฐ”๋กœ๊ฐ€๊ธฐ
Unix·๏ปฟLinux

๋ฆฌ๋ˆ…์Šค ๊ฐ€์ƒ๋จธ์‹ ์— PuTTY๋กœ SSH ์›๊ฒฉ ์ ‘์†ํ•˜๋Š” ๋ฐฉ๋ฒ•

by Leica 2019. 12. 12.
๋ฐ˜์‘ํ˜•

์ค€๋น„ ์‚ฌํ•ญ

1. ๋ฆฌ๋ˆ…์Šค ๋จธ์‹ ์—์„œ sshd ๋ฐ๋ชฌ ์‹คํ–‰ ์ƒํƒœ ํ™•์ธ
2. ๋ฆฌ๋ˆ…์Šค ๋จธ์‹ ์—์„œ ssh ํฌํŠธ ๋ฐฉํ™”๋ฒฝ ํ—ˆ์šฉ ํ™•์ธ
3. ๋ฆฌ๋ˆ…์Šค ๋จธ์‹ ์—์„œ ํ˜ธ์ŠคํŠธ allow ์„ค์ •
4. ๊ฐ€์ƒ๋จธ์‹  ํฌํŠธ ํฌ์›Œ๋”ฉ ์„ค์ •
5. ์œˆ๋„์šฐ PC์—์„œ PuTTY ํ”„๋กœ๊ทธ๋žจ ์ค€๋น„

๊ธฐ๋ณธ์ ์œผ๋กœ SSH ์›๊ฒฉ ์ ‘์†์„ ํ•˜๋ ค๋ฉด ๋Œ€์ƒ ๋ฆฌ๋ˆ…์Šค ๋จธ์‹ ์—์„œ sshd ๋ฐ๋ชฌ์ด ์‹คํ–‰์ค‘์ด๊ณ  ๋ฐฉํ™”๋ฒฝ์ด ํ—ˆ์šฉ ์ƒํƒœ์—ฌ์•ผ ํ•œ๋‹ค. ์œˆ๋„์šฐ์—์„œ๋Š” PuTTY๋ฅผ ์ด์šฉํ•ด ์ ‘์†ํ•  ์ˆ˜ ์žˆ๋‹ค.

 

SSH(Secure Shell)

- ๋ณดํ˜ธ๋œ ์›๊ฒฉ ๋กœ๊ทธ์ธ, ์›๊ฒฉ ๋ฐ์ดํ„ฐ ํ†ต์‹ ์— ์‚ฌ์šฉ๋˜๋Š” ํ”„๋กœํ† ์ฝœ
- ํŒจํ‚ท์„ ์•”ํ˜ธํ™”ํ•˜์—ฌ ์ „์†กํ•˜๊ธฐ ๋•Œ๋ฌธ์— ๋„์ฒญ, ์œ„๋ณ€์กฐ ์ฐจ๋‹จ์ด ๊ฐ€๋Šฅ
- ์„œ๋ฒ„/ํด๋ผ์ด์–ธํŠธ ๊ตฌ์กฐ๋กœ ๋™์ž‘ํ•˜๋ฉฐ ๋ณดํ†ต TCP ํฌํŠธ 22 ์‚ฌ์šฉ

 

SSH๋ฅผ ์‚ฌ์šฉํ•˜๊ธฐ ์œ„ํ•ด์„œ๋Š” SSH ์ง€์› ๋„๊ตฌ๊ฐ€ ์„œ๋ฒ„, ํด๋ผ์ด์–ธํŠธ์— ๋ชจ๋‘ ํ•„์š”ํ•˜๋‹ค.

 

* SSH ์„œ๋ฒ„ ํ”„๋กœ๊ทธ๋žจ : sshd

* SSH ํด๋ผ์ด์–ธํŠธ ํ”„๋กœ๊ทธ๋žจ : ssh, sftp, scp ๋“ฑ ์‚ฌ์šฉ ๋ชฉ์ ์— ๋”ฐ๋ผ ๋‹ค์–‘

 

์—ฌ๊ธฐ์„œ๋Š” ์›๊ฒฉ ์ ‘์†์„ ํ•  ๊ฒƒ์ด๋ฏ€๋กœ ssh ํด๋ผ์ด์–ธํŠธ ํ”„๋กœ๊ทธ๋žจ์ด ํ•ด๋‹น๋œ๋‹ค.

 

OpenSSH ํŒจํ‚ค์ง€

- SSH ํ”„๋กœํ† ์ฝœ์„ ์‚ฌ์šฉํ•˜๋Š” ๊ณต๊ฐœ ์†Œ์Šค ํ”„๋กœ๊ทธ๋žจ ํŒจํ‚ค์ง€
- ์„œ๋ฒ„ ํ”„๋กœ๊ทธ๋žจ์ธ sshd์™€ ํด๋ผ์ด์–ธํŠธ ํ”„๋กœ๊ทธ๋žจ๋“ค์„ ๋ชจ๋‘ ํฌํ•จํ•œ๋‹ค.

ํ˜„์žฌ ๋Œ€๋ถ€๋ถ„์˜ ๋ฆฌ๋ˆ…์Šค ๋ฐฐํฌํŒ์—๋Š” OpenSSH๊ฐ€ ํฌํ•จ๋˜์–ด ์žˆ์–ด ๋ณดํ†ต ๋ณ„๋„ ์„ค์น˜๊ฐ€ ํ•„์š”ํ•˜์ง€ ์•Š๋‹ค.

 

OpenSSH ์„ค์น˜ ํ™•์ธ ๋ฐฉ๋ฒ•

[user1@localhost ~]$ yum list installed | grep openssh
openssh.i686            5.3p1-123.el6_9  @anaconda-CentOS-201806291517.i386/6.10
openssh-askpass.i686    5.3p1-123.el6_9  @anaconda-CentOS-201806291517.i386/6.10
openssh-clients.i686    5.3p1-123.el6_9  @anaconda-CentOS-201806291517.i386/6.10
openssh-server.i686     5.3p1-123.el6_9  @anaconda-CentOS-201806291517.i386/6.10
cs

yum list installed | grep openssh ๋ช…๋ น์œผ๋กœ OpenSSH ํŒจํ‚ค์ง€ ์„ค์น˜ ํ™•์ธ์ด ๊ฐ€๋Šฅํ•˜๋‹ค. ์œ„์™€ ์œ ์‚ฌํ•œ ๊ฒฐ๊ณผ๊ฐ€ ๋‚˜์˜ค๋ฉด ํŒจํ‚ค์ง€๊ฐ€ ์ด๋ฏธ ์„ค์น˜๋œ ๊ฒƒ์ด๋‹ค.

 

yum -y install openssh    # OpenSSH ํŒจํ‚ค์ง€ ์„ค์น˜
yum -y update openssh     # OpenSSH ํŒจํ‚ค์ง€ ์—…๋ฐ์ดํŠธ
cs

OpenSSH ํŒจํ‚ค์ง€๋ฅผ ์„ค์น˜ํ•˜๊ฑฐ๋‚˜ ์ด๋ฏธ ์„ค์น˜๋œ ํŒจํ‚ค์ง€๋ฅผ ์—…๋ฐ์ดํŠธ ํ•˜๋ ค๋ฉด ๊ฐ๊ฐ ์œ„์™€ ๊ฐ™์ด ์ž…๋ ฅํ•œ๋‹ค.

 

SSH ์„œ๋ฒ„ ์‹คํ–‰

๊ฐ€์ƒ ๋จธ์‹ ์˜ ๋ฆฌ๋ˆ…์Šค๋กœ ์›๊ฒฉ ์ ‘์†ํ•˜๊ธฐ ์œ„ํ•ด์„œ๋Š” SSH ์„œ๋ฒ„ ํ”„๋กœ๊ทธ๋žจ์ธ sshd ๋ฐ๋ชฌ์ด ์‹คํ–‰์ค‘์ธ ์ƒํƒœ์—ฌ์•ผ ํ•œ๋‹ค. sshd ์‹คํ–‰ ์ƒํƒœ๋Š” service sshd status ๋ช…๋ น์œผ๋กœ ํ™•์ธํ•  ์ˆ˜ ์žˆ๋‹ค. OpenSSH ํŒจํ‚ค์ง€๊ฐ€ ์ด๋ฏธ ์„ค์น˜๋˜์–ด ์žˆ๋‹ค๋ฉด ๊ธฐ๋ณธ์ ์œผ๋กœ ๋ถ€ํŒ… ์‹œ ์ž๋™์œผ๋กœ ์‹คํ–‰๋˜๋„๋ก ์„ค์ •๋˜์–ด ์žˆ์–ด sshd ๋ฐ๋ชฌ๋„ ์‹คํ–‰ ์ค‘์ผ ๊ฐ€๋Šฅ์„ฑ์ด ๋†’๋‹ค.

[user1@localhost ~]$ service sshd status
openssh-daemon (pid  2324) is running...
cs

 

service sshd start    # sshd ์‹คํ–‰
chkconfig sshd on     # ๋ถ€ํŒ… ์‹œ sshd ์ž๋™ ์‹คํ–‰ 
cs

์‹คํ–‰์ค‘์ด์ง€ ์•Š์œผ๋ฉด service sshd start ๋ช…๋ น์œผ๋กœ ์‹คํ–‰ํ•œ๋‹ค. ๋ถ€ํŒ… ์‹œ sshd๊ฐ€ ์ž๋™์œผ๋กœ ์‹คํ–‰๋˜๊ฒŒ ํ•˜๋ ค๋ฉด chkconfig sshd on ๋ช…๋ น์„ ์ž…๋ ฅํ•œ๋‹ค.

 

๋ฐฉํ™”๋ฒฝ ์„ค์ •

SSH๊ฐ€ ์‚ฌ์šฉํ•˜๋Š” 22๋ฒˆ ํฌํŠธ๋ฅผ ํ—ˆ์šฉํ•˜๋„๋ก ๋ฐฉํ™”๋ฒฝ ์„ค์ •์ด ๋˜์–ด์žˆ์–ด์•ผ ํ•œ๋‹ค. iptables -nL ๋ช…๋ น์„ ์ž…๋ ฅํ•˜์—ฌ ๋‹ค์Œ์˜ ACCEPT...tcp dpt:22์ฒ˜๋Ÿผ INPUT ์ฒด์ธ์— tcp ๋ชฉ์ ์ง€ ํฌํŠธ 22๊ฐ€ ํ—ˆ์šฉ ์„ค์ •์ด ๋˜์–ด์žˆ๋Š”์ง€ ํ™•์ธํ•œ๋‹ค.

[user1@localhost ~]$ iptables -nL
Chain INPUT (policy ACCEPT)
target     prot opt source               destination
ACCEPT     all  --  0.0.0.0/0            0.0.0.0/0           state RELATED,ESTABLISHED
ACCEPT     icmp --  0.0.0.0/0            0.0.0.0/0
ACCEPT     all  --  0.0.0.0/0            0.0.0.0/0
ACCEPT     tcp  --  0.0.0.0/0            0.0.0.0/0           state NEW tcp dpt:22
REJECT     all  --  0.0.0.0/0            0.0.0.0/0           reject-with icmp-host-prohibited
 
Chain FORWARD (policy ACCEPT)
target     prot opt source               destination
REJECT     all  --  0.0.0.0/0            0.0.0.0/0           reject-with icmp-host-prohibited
 
Chain OUTPUT (policy ACCEPT)
target     prot opt source               destination
cs

 

๊ทธ๋ ‡์ง€ ์•Š์œผ๋ฉด iptables -A INPUT -p tcp -m tcp --dport 22 -j ACCEPT ๋ฅผ ์ž…๋ ฅํ•˜์—ฌ SSH ์ ‘์† ํ—ˆ์šฉ ์„ค์ •์„ ํ•˜๊ณ  service iptables save๋ฅผ ์ž…๋ ฅํ•˜์—ฌ ์ €์žฅํ•œ๋‹ค.

[user1@localhost ~]$ iptables -A INPUT -p tcp -m tcp --dport 22 -j ACCEPT
[user1@localhost ~]$ service iptables save
cs

 

ํ˜ธ์ŠคํŠธ allow ์„ค์ •

๋ฆฌ๋ˆ…์Šค ๋จธ์‹ ์˜ TCP/IP ์„œ๋น„์Šค๋ฅผ ์ด์šฉํ•  ์ˆ˜ ์žˆ๋Š” ํ˜ธ์ŠคํŠธ๋ฅผ ์„ค์ •ํ•œ๋‹ค.

 

VirtualBox์˜ [ํŒŒ์ผ] - [ํ˜ธ์ŠคํŠธ ๋„คํŠธ์›Œํฌ ๊ด€๋ฆฌ์ž] ๋ฉ”๋‰ด๋ฅผ ํด๋ฆญํ•œ๋‹ค.

 

ํ˜ธ์ŠคํŠธ ๋„คํŠธ์›Œํฌ ๊ด€๋ฆฌ์ž ์ฐฝ์—์„œ VirtualBox Host-Only Ehternet Adapter์˜ IP์ฃผ์†Œ๋ฅผ ํ™•์ธํ•œ๋‹ค.

 

 

/etc/hosts.allow ํŒŒ์ผ์„ ํŽธ์ง‘ํ•˜๊ธฐ ์œ„ํ•ด vi /etc/hosts.allow๋ฅผ ์ž…๋ ฅํ•œ๋‹ค.

[user1@localhost ~]$ vi /etc/hosts.allow
cs

 

#
# hosts.allow   This file contains access rules which are used to
#               allow or deny connections to network services that
#               either use the tcp_wrappers library or that have been
#               started through a tcp_wrappers-enabled xinetd.
#
#               See 'man 5 hosts_options' and 'man 5 hosts_access'
#               for information on rule syntax.
#               See 'man tcpd' for information on tcp_wrappers
#
sshd: 12.34.56.78
cs

์œ„์™€ ๊ฐ™์ด sshd: ๋’ค์— VirtualBox Host-Only Ehternet Adapter์˜ IP์ฃผ์†Œ๋ฅผ ์ž…๋ ฅํ•˜๊ณ  ์ €์žฅํ•œ๋‹ค.

 

PuTTY๋กœ ์ ‘์†

PuTTY๋Š” ์œˆ๋„์šฐ์—์„œ ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ๋Š” SSH ํด๋ผ์ด์–ธํŠธ ํ”„๋กœ๊ทธ๋žจ์ด๋‹ค. ํ”„๋กœ๊ทธ๋žจ์ด ์—†์„ ๊ฒฝ์šฐ ์•„๋ž˜ URL์—์„œ ๋‹ค์šด๋กœ๋“œ ๋ฐ›์„ ์ˆ˜ ์žˆ๋‹ค.

 

https://www.chiark.greenend.org.uk/~sgtatham/putty/latest.html

 

Download PuTTY: latest release (0.73)

This page contains download links for the latest released version of PuTTY. Currently this is 0.73, released on 2019-09-29. When new releases come out, this page will update to contain the latest, so this is a good page to bookmark or link to. Alternativel

www.chiark.greenend.org.uk

 

putty.exe ๋‹ค์šด๋กœ๋“œ

 

์ ‘์†ํ•  ๋ฆฌ๋ˆ…์Šค ๋จธ์‹ ์˜ IP์ฃผ์†Œ๋ฅผ ์•Œ์•„์•ผ ํ•˜๋ฏ€๋กœ ifconfig ๋ช…๋ น์–ด๋ฅผ ์ž…๋ ฅํ•˜์—ฌ IP์ฃผ์†Œ๋ฅผ ํ™•์ธํ•œ๋‹ค.

[user1@localhost ~]$ ifconfig
eth0      Link encap:Ethernet  HWaddr 08:00:27:F1:7E:0C
          inet addr:10.0.2.15  Bcast:10.0.2.255  Mask:255.255.255.0
cs

์œ„์™€ ๊ฐ™์€ ์ถœ๋ ฅ ๊ฒฐ๊ณผ์—์„œ IP์ฃผ์†Œ๋Š” 10.0.2.15์ด๋‹ค.

 

๋Œ€์ƒ ๋จธ์‹ ์„ ์„ ํƒํ•˜๊ณ  [์„ค์ •]์„ ํด๋ฆญํ•œ๋‹ค.

 

[๋„คํŠธ์›Œํฌ] ๋ฉ”๋‰ด๋ฅผ ํด๋ฆญํ•˜๊ณ  [๊ณ ๊ธ‰] - [ํฌํŠธ ํฌ์›Œ๋”ฉ]์„ ํด๋ฆญํ•œ๋‹ค.

 

+ ์•„์ด์ฝ˜์„ ํด๋ฆญํ•œ๋‹ค.

 

ํ”„๋กœํ† ์ฝœ์€ TCP, ํ˜ธ์ŠคํŠธ IP๋Š” VirtualBox Host-Only Ehternet Adapter IP, ๊ฒŒ์ŠคํŠธ IP๋Š” ifconfig ๋ช…๋ น์œผ๋กœ ํ™•์ธํ•œ IP, ํฌํŠธ๋Š” 22๋ฅผ ์ž…๋ ฅํ•˜๊ณ  ํ™•์ธ์„ ํด๋ฆญํ•œ๋‹ค.

 

PuTTY๋ฅผ ์‹คํ–‰ํ•˜๊ณ  Host Name์— VirtualBox Host-Only Ehternet Adapter IP๋ฅผ, Port์— 22๋ฅผ ์ž…๋ ฅํ•˜๊ณ  Open์„ ํด๋ฆญํ•œ๋‹ค.

 

๊ทธ๋Ÿฌ๋ฉด ์œ„์™€ ๊ฐ™์ด ์ •์ƒ ์ ‘์†๋จ์„ ํ™•์ธํ•  ์ˆ˜ ์žˆ๋‹ค. VirtualBox ์ฝ˜์†”์ฐฝ๊ณผ ๋งˆ์ฐฌ๊ฐ€์ง€๋กœ ์‚ฌ์šฉ์ž ๊ณ„์ •์œผ๋กœ ๋กœ๊ทธ์ธํ•˜์—ฌ ์‚ฌ์šฉํ•˜๋ฉด ๋œ๋‹ค.

 

๊ด€๋ จ ํฌ์ŠคํŠธ

[OS/Unix·Linux] - ๋ฆฌ๋ˆ…์Šค(CentOS 6) ์„ค์น˜ํ•˜๊ธฐ - ๊ฐ€์ƒ๋จธ์‹  VirtualBox๋ฅผ ์ด์šฉํ•˜์—ฌ

 

๋ฆฌ๋ˆ…์Šค(CentOS 6) ์„ค์น˜ํ•˜๊ธฐ - ๊ฐ€์ƒ๋จธ์‹  VirtualBox๋ฅผ ์ด์šฉํ•˜์—ฌ

์ด๋ฏธ ์œˆ๋„์šฐ ์šด์˜์ฒด์ œ๊ฐ€ ์„ค์น˜๋œ PC์— ๋ฆฌ๋ˆ…์Šค๋ฅผ ์ถ”๊ฐ€๋กœ ์„ค์น˜ํ•˜๋Š” ๋ฐฉ๋ฒ•์—๋Š” ๋‘ ๊ฐ€์ง€ ๋ฐฉ๋ฒ•์ด ์žˆ๋‹ค. ํ•˜๋“œ ๋””์Šคํฌ์˜ ๋น„์–ด์žˆ๋Š” ํŒŒํ‹ฐ์…˜์— ์„ค์น˜ '๊ฐ€์ƒ๋จธ์‹  ์†Œํ”„ํŠธ์›จ์–ด'๋ฅผ ์ด์šฉํ•˜์—ฌ ๊ฒŒ์ŠคํŠธ ์šด์˜์ฒด์ œ๋กœ ์„ค์น˜ ๋ณธ ํฌ์ŠคํŒ…์—์„œ๋Š”..

atoz-develop.tistory.com

[OS/Unix·Linux] - ๋ฆฌ๋ˆ…์Šค(CentOS 6) ๊ทธ๋ž˜ํ”ฝ ๋ชจ๋“œ์™€ ํ…์ŠคํŠธ ๋ชจ๋“œ ์ „ํ™˜ํ•˜๋Š” ๋ฐฉ๋ฒ•

 

๋ฆฌ๋ˆ…์Šค(CentOS 6) ๊ทธ๋ž˜ํ”ฝ ๋ชจ๋“œ์™€ ํ…์ŠคํŠธ ๋ชจ๋“œ ์ „ํ™˜ํ•˜๋Š” ๋ฐฉ๋ฒ•

๋ฆฌ๋ˆ…์Šค๋Š” ๋ถ€ํŒ… ์‹œ init ํ”„๋กœ์„ธ์Šค๊ฐ€ ๋Ÿฐ๋ ˆ๋ฒจ์„ ํ™•์ธํ•˜์—ฌ ๊ทธ์— ๋งž๋Š” ์„œ๋น„์Šค๋ฅผ ์‹œ์ž‘์‹œํ‚ค๋Š” ๊ณผ์ •์ด ์žˆ๋‹ค. ์ด ๋Ÿฐ๋ ˆ๋ฒจ์„ ๋ฐ”๊พธ์–ด ๊ทธ๋ž˜ํ”ฝ ๋ชจ๋“œ ํ˜น์€ ํ…์ŠคํŠธ ๋ชจ๋“œ๋กœ ๋ถ€ํŒ…ํ•  ์ˆ˜ ์žˆ๋‹ค. ๋Ÿฐ๋ ˆ๋ฒจ์€ 0์—์„œ 6๊นŒ์ง€์˜ 7๊ฐ€์ง€๊ฐ€ ์กด์žฌํ•˜..

atoz-develop.tistory.com

[OS/Unix·Linux] - VirtualBox ๋ณต์‚ฌ, ๋ถ™์—ฌ๋„ฃ๊ธฐ๋ฅผ ์œ„ํ•œ ํด๋ฆฝ๋ณด๋“œ ๊ณต์œ  ์„ค์ • ๋ฐฉ๋ฒ•

 

VirtualBox ๋ณต์‚ฌ, ๋ถ™์—ฌ๋„ฃ๊ธฐ๋ฅผ ์œ„ํ•œ ํด๋ฆฝ๋ณด๋“œ ๊ณต์œ  ์„ค์ • ๋ฐฉ๋ฒ•

๊ฐ€์ƒ๋จธ์‹  ์†Œํ”„ํŠธ์›จ์–ด์ธ VirtualBox๋กœ ๋ฆฌ๋ˆ…์Šค ๋“ฑ์„ ๊ฒŒ์ŠคํŠธ ์šด์˜์ฒด์ œ๋กœ ์„ค์น˜ํ•˜์—ฌ ์‚ฌ์šฉํ•  ๋•Œ ๋ณต์‚ฌ, ๋ถ™์—ฌ๋„ฃ๊ธฐ๊ฐ€ ํ•„์š”ํ•œ ๊ฒฝ์šฐ๊ฐ€ ์ข…์ข… ์žˆ๋‹ค. ์ด ๋•Œ VirtualBox ํด๋ฆฝ๋ณด๋“œ ๊ณต์œ  ์„ค์ •์„ ํ†ตํ•ด ํ•ด๋‹น ๊ธฐ๋Šฅ์„ ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ๋Š”๋ฐ..

atoz-develop.tistory.com

๋ฐ˜์‘ํ˜•

๋Œ“๊ธ€