SSH

Installation

원격으로 시스템에 접속하기 위해 SSH를 설치한다.

$ sudo apt-get install openssh-server

설치가 끝나면 systemctl statussshd가 동작 중임을 확인할 수 있다.

$ sudo systemctl status ssh
[sudo] password for jkpark: 
● ssh.service - OpenBSD Secure Shell server
   Loaded: loaded (/lib/systemd/system/ssh.service; enabled; vendor preset: enabled)
   Active: active (running) since Sun 2019-02-24 23:58:33 EST; 1min 58s ago
  Process: 1055 ExecStartPre=/usr/sbin/sshd -t (code=exited, status=0/SUCCESS)
 Main PID: 1067 (sshd)
    Tasks: 1 (limit: 4603)
   CGroup: /system.slice/ssh.service
           └─1067 /usr/sbin/sshd -D

Feb 24 23:58:33 cactus systemd[1]: Starting OpenBSD Secure Shell server...
Feb 24 23:58:33 cactus sshd[1067]: Server listening on 0.0.0.0 port 22.
Feb 24 23:58:33 cactus sshd[1067]: Server listening on :: port 22.
Feb 24 23:58:33 cactus systemd[1]: Started OpenBSD Secure Shell server.

Port 옵션의 주석을 해제하고 원하는 포트로 설정한다. 나는 기본 포트를 사용할 것이므로 설정하지 않았다. 바로 아래 라인에 AllowUsers 항목을 추가하여 접속 허용할 사용자명을 지정할 수도 있다.

#       $OpenBSD: sshd_config,v 1.101 2017/03/14 07:19:07 djm Exp $

# This is the sshd server system-wide configuration file.  See
# sshd_config(5) for more information.

# This sshd was compiled with PATH=/usr/bin:/bin:/usr/sbin:/sbin

# The strategy used for options in the default sshd_config shipped with
# OpenSSH is to specify options with their default value where
# possible, but leave them commented.  Uncommented options override the
# default value.

Port 22
AllowUsers jkpark

:wq 을 입력하고 저장 후 편집을 종료한다.

설정을 마쳤으면 ssh 서비스를 재시작한다.

$ sudo systemctl restart ssh.service

Last updated

Was this helpful?