有时候Linux 主机之间传文件需要输密码,或者SSH登陆输需要密码,比较麻烦,可以通过以下方法配置。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
|
1. Setup a new directory ".ssh" under the home folder: $ mkdir .ssh
2. Set the priority of ".ssh" as drwxr-xr-x: $ chmod 755 .ssh
3. Generating public key of the namenode for passphraseless SSH $ ssh-keygen -t rsa $ ssh-keygen -t dsa and press three "Enter"s
4. Add the public key SSH to authorized key list: If "~/.ssh/authorized_keys" does not exit: $ cp ~/.ssh/id_rsa.pub ~/.ssh/authorized_keys Else appending: $ cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys $ cat ~/.ssh/id_dsa.pub >> ~/.ssh/authorized_keys
|
经以上配置后,scp文件到目标主机或者 ssh 登陆 不需要输入密码了。不过,如果不是特殊需要,最好不要这么做,有风险。
原创文章,作者:254126420,如若转载,请注明出处:https://blog.ytso.com/tech/database/236347.html