![]() ![]() Here, my_secret_password is the password of alice on host2. We also provide the password from the command line using -p my_secret_password. ![]() ![]() This time, we pass the ssh-copy-id command as the command that will be run by sshpass. Now, instead of directly using ssh-copy-id, let’s use it together with sshpass: ]$ sshpass –p my_secret_password ssh-copy-id In the earlier example, ssh-copy-id had copied our public key into this file.įinally, after logging out of host2 using exit, we try to reconnect from host1 to host2. Then, we delete the file /home/alice/.ssh/authorized_keys on host2. It would be nice to automate the process to use in shell scripts. If we’re the system administrator and want to configure the system for SSH connections without using passwords, then it’s tedious to enter the password manually for each host while using ssh-copy-id. Then, what’s the problem? We may have many remote hosts with the same username and password combination. Therefore, we’re able to successfully log in to host2 from host1 without using passwords. This time, ssh doesn’t ask for the password. Now, let’s test whether connecting from host1 to host2 asks for the password: ]$ ssh host2 Now try logging into the machine, with: "ssh ' '"Īnd check to make sure that only the key(s) you wanted were added.Īfter we enter the password of alice on host2, ssh-copy-id informs us that the key was added. usr/bin/ssh-copy-id: INFO: 1 key(s) remain to be installed – if you are prompted now it is to install the new keysĪfter printing a bunch of information, ssh-copy-id asks for the password of alice on host2. usr/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed usr/bin/ssh-copy-id: INFO: Source of key(s) to be installed: "home/alice/.ssh/id_rsa.pub" ![]()
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |