In linux, the ssh password-free approach requires switching between different hosts or scp during daily development or O & M, repeated Password Input in an intranet trusted network environment is a tedious task to test your memory, therefore, we can use the ssh-keygen tool to configure ssh authorization between common machines to save the process of entering the password. To access B from A directly using ssh without A password (using the account zhangsan), follow these steps: 1. log on to A and switch to zhangsan: su-zhangsan; 2. generate public key and private key: the Java code ssh-keygen-t dsa, where the-t parameter can be followed by dsa or rsa. The specific type depends on the machine environment, and most of them should be dsa. After you press enter ~ The id_dsa and id_dsa.pub files are generated under the zhangsan/. ssh/directory. The id_dsa.pub file is a public key file and needs to be copied to the target and its B files. Www.2cto.com 3. Copy the public key to the target machine: scp id_dsa.pub zhangsan @ B:/home/zhangsan/. ssh/id_dsa.pub.A 4. append it to the target machine ~ /. Ssh/authorized_keys ~ /. Ssh/cat id_dsa.pub.A> ~ /. Ssh/authorized_keys is complete.