Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 7 Next »

ssh 는 public key, password, host based 등 다양한 인증 방법을 제공하고 있음.


ssh client 설정

ssh config 에 설정

ssh 의 개인 설정 파일인 ~/.ssh/config 파일에 호스트 정보와 선호하는 인증 방식을 지정

~/.ssh/config
Host example
    Host example.com
    User ec2-user
    Port 10022
    PreferredAuthentications publickey
    IdentityFile ~/.ssh/example/id_rsa


연결할 경우 Host 에 지정한 이름 사용

ssh example



command 에서 옵션으로 지정


id/password 

ssh -o PreferredAuthentications=password -o PubkeyAuthentication=no ec2-user@example.com


public key 

사용하는 개인키 명이 ~/.ssh/id_rsa 가 아닐 경우 -i 옵션으로 개인키 지정 필요

ssh -o PreferredAuthentications=publickey -o PasswordAuthentication=no -i ~/.ssh/example/id_rsa ec2-user@example.com


ssh 서버 설정

보안을 위해서는 공개키 방식만 사용하는 것이 좋지만 특정 사용자만 패스워드 방식이 필요할 경우 Match 키워드 사용해서 지정

/etc/ssh/sshd_config
PubkeyAuthentication
PasswordAuthentication no

# 접속을 허용할 사용자 계정
AllowUsers lesstif centos7 ec2-user


# lesstif, centos7 사용자만 암호 로그인 허용
Match User lesstif,centos7 
    PasswordAuthentication yes

Match 키워드는 설정 파일 맨 아래에 위치해야 함


Ref

  • No labels