Sử dụng SSHPass để tự động nhập mật khẩu khi xác thực mật khẩu. Điều này thuận tiện nhưng có rủi ro về bảo mật (rò rỉ mật khẩu), hãy đặc biệt cẩn thận nếu bạn sử dụng nó. | |
[1] | Cài đặt SSHPass. |
root@dlp:~# apt -y install sshpass
|
[2] | Cách sử dụng SSHPass. |
# [-p password] : from argument # if initial connection, add [StrictHostKeyChecking=no] ubuntu@dlp:~$ sshpass -p password ssh -o StrictHostKeyChecking=no 10.0.0.51 hostname node01.srv.world # [-f file] : from file ubuntu@dlp:~$ echo 'password' > sshpass.txt ubuntu@dlp:~$ chmod 600 sshpass.txt ubuntu@dlp:~$ sshpass -f sshpass.txt ssh 10.0.0.51 hostname node01.srv.world # [-e] : from environment variable ubuntu@dlp:~$ export SSHPASS=password ubuntu@dlp:~$ sshpass -e ssh 10.0.0.51 hostname node01.srv.world |