SSH 서버를 구성하면 원격 컴퓨터에서 서버에 접속하여 조작할 수 있습니다.
SSH 서버 설정
Rocky Linux 최소 구성 설치에서 기본적으로 OpenSSH가 설치되고 자동 부팅 설정이 되어 있기 때문에 패스워드 인증 방식으로 바로 로그인 할 수 있습니다. 단, 기본적으로 root 계정의 직접 로그인이 가능한 설정이 기본값이기 때문에 아래와 같이 sshd_config 파일의 43번째 줄을 고쳐 root 계정의 직접 로그인 금지 설정을 해둘 수도 있습니다.
[root@samplehost ~]# vi /etc/ssh/sshd_config
PermitRootLogin no
[root@samplehost ~]# systemctl restart sshd
Firewalld가 유효화되어 있는 경우는 SSH 서비스에 대한 별도의 허가가 필요합니다. SSH는 22/TCP 를 사용합니다.
[root@samplehost ~]# firewall-cmd --add-service=ssh
success
[root@samplehost ~]# firewall-cmd --runtime-to-permanent
success
SSH 클라이언트 설정 : Rocky Linux
Rocky Linux에서의 SSH 클라이언트의 설정입니다. SSH 클라이언트가 설치되어있지 않다면 아래 커맨드를 이용해 설치해줍니다.
[root@samplehost ~]# dnf -y install openssh-clients
임의의 일반 사용자로 SSH 서버에 접속합니다. 접속 시에는 “ssh 유저명@호스트명 또는 IP주소”의 형식의 커맨드를 사용합니다.
[root@samplehost ~]# ssh testuser01@samplehost
The authenticity of host 'samplehost (fe80::215:5dff:fe3f:121%eth0)' can't be established.
ED25519 key fingerprint is SHA256:CU4O6ZFy8shTfqq5S6FBCC1scNvgbUXPh9r++7KQdtA.
This host key is known by the following other names/addresses:
~/.ssh/known_hosts:1: 192.168.74.250
Are you sure you want to continue connecting (yes/no/[fingerprint])? yes
Warning: Permanently added 'samplehost' (ED25519) to the list of known hosts.
testuser01@samplehost's password:
Web console: https://samplehost:9090/ or https://192.168.74.250:9090/
Last login: Sun Aug 4 11:57:54 2024 from fe80::215:5dff:fe3f:121%eth0
[testuser01@samplehost ~]$
SSH 명령어 인수에 명령어를 지정함으로써 원격 호스트에서 임의의 명령어를 실행할 수 있습니다. 예시로 리모트 호스트의 /etc/passwd 를 cat 커맨드로 열람하겠습니다.
[root@samplehost ~]# ssh testuser01@samplehost "cat /etc/passwd"
testuser01@samplehost's password:
root:x:0:0:root:/root:/bin/bash
bin:x:1:1:bin:/bin:/sbin/nologin
...중간 생략...
tempuser:x:1002:1002::/home/tempuser:/bin/bash
testuser01:x:1003:1003::/home/testuser01:/bin/bash
postgres:x:26:26:PostgreSQL Server:/var/lib/pgsql:/bin/bash
testuser:x:1004:1004::/home/testuser:/bin/bash
testuser02:x:1005:1007::/home/testuser02:/bin/bash
[root@samplehost ~]#
SSH 클라이언트 설정 : Windows1
Windows 환경의 SSH 클라이언트의 설정입니다.
우선 Windows 클라이언트 측에서 SSH 클라이언트 소프트웨어를 준비합니다. 이 글에서는 일반적으로 많이 쓰이는 Putty를 사용하겠습니다.
Putty 화면에서 “Host Name(or IP address)”에 서버의 호스트 이름 또는 IP 주소를 입력하고 “Open” 버튼을 클릭합니다. Port는 디폴트값으로 22, Connection type은 SSH, Telnet입니다.

사용자 이름과 비밀번호를 입력하고 인증하면 아래와 같이 Rocky Linux 서버에 SSH로 원격 로그인 할 수 있습니다.

SSH 클라이언트 설정 : Windows2
Windows 10 버전 1803 이상의 환경을 사용 중이라면 OpenSSH 클라이언트가 표준으로 제공되고 있기 때문에 SSH 클라이언트를 따로 준비하지 않아도 파워쉘을 통해 SSH 서버에 접속이 가능합니다.

ssh -V //OpenSSH 클라이언트 버전 확인
ssh 유저명@서버IP주소 //SSH 서버 접속
댓글