Đầu tiên bạn sẽ yêu cầu user đó gửi public key cho bạn.
Có kiểu như bên dưới.
Trên server mà User muốn SSH
the command is creating a new user named “thangta” with the login shell set to /bin/bash
, no additional information in the GECOS field, and a disabled password. This is often used for system accounts or accounts that are used for specific purposes and don’t require password-based login.
adduser --shell /bin/bash --gecos "" --disabled-password thangta mkdir /home/thangta/.ssh cd .ssh/ ===> add id_rsa.pub conntent to the below file. nano /home/thangta/.ssh/authorized_keys
Nếu bạn muốn user đó có quyền “sudo -i” thì làm thêm lệnh dưới.
nano /etc/sudoers.d/thangta thangta ALL=(ALL:ALL) NOPASSWD: ALL
Monitoring SSH
Bạn có thể tham khảo:
https://github.com/shizunge/endlessh-go