MQTT broker 암호화

- user password 설정

* mosquitto broker가 설치되어있는 환경기반으로 진행된것이므로 broker가 없다면 설치 후 진행

 

# cd /etc/mosquitto  //-- mosquitto위치로 이동

# vi mosquitto.conf  //--설정파일 맨 밑에 추가

# 비밀번호 파일경로 설정
password_file /etc/mosquitto/passwd

# 익명접속차단
allow_anonymous false

 

# vi /etc/mosquitto/passwd   // 비밀번호 파일생성

# username:password
user:1234

 

# mosquitto_passwd -U /etc/mosquitto/passwd  // passwd 파일암호화

# cat passwd  // 암호화 확인

# service mosquitto stop  
# service mosquitto start

 

# mosquitto_sub -h localhost -t /topic  //-- 유저 지정이 없을경우 connection error

 

# mosquitto_sub -h localhost -t /topic -u user -P 1234   // subscribe

# mosquitto_pub -h localhost -t /topic -u user -P 1234 -m "test"  //publish

 

Tip) user 추가시 "mosquitto_passwd -b PW파일위치 ID PW" 로 설정가능 
# mosquitto_passwd -b /etc/mosquitto/passwd admin root1234

'개발일지 > 기타' 카테고리의 다른 글

[Android] FCM push 1  (0) 2020.12.16
docker container를 image로 저장 후 tar 생성  (0) 2020.11.26
이클립스 zip 파일 import  (0) 2020.10.06

+ Recent posts