2018-03-07

[AWS] EC2처럼 SSH 사용하기 및 패스워드 인증 방식으로 로그인



AWS EC2처럼 SSH 사용하기
http://blog.flative.io/2017/01/03/like-aws/

[AWS] EC2 Instance에 key-pair 없이 로그인 하기(Ubuntu)
http://ggang9.tistory.com/22


1. root 패스워드 설정
sudo passwd root

2. ssh 패스워드 방식으로 접근 허용
vi /etc/ssh/sshd_config
PasswordAuthentication yes

LoginGraceTime 2m (120)
PermitRootLogin forced-commands-only <= centos 일 경우
PermitRootLogin prohibit-password  <= ubuntu 일 경우
StrictModes yes

=> 인증서도 같이 사용하기 위해서
RSAAuthentication yes
PubkeyAuthentication yes
# AuthorizedKeysFile .ssh/authorized_keys <= 주석처리 해줌.

3. 유저(ec2-user, ubuntu)의 인증서를 root의 .ssh로 복사
sudo cp /home/ubuntu/.ssh/authorized_keys /root/.ssh/
sudo cp /home/ec2-user/.ssh/authorized_keys /root/.ssh/

4. 필요하면 문구 추가해줌.
=> After that make sure the "/root/.ssh/authorized_keys" file should start with ssh-rsa content
no-port-forwarding,no-agent-forwarding,no-X11-forwarding,command="echo 'Please login as the user \"ubuntu\" rather than the user \"root\".';echo;sleep 10"

5. ssh restart
sudo service ssh restart

댓글 없음:

댓글 쓰기