Ssh copy id port11/7/2023 ![]() So the remote ssh instance will have a TTY and it will prompt the user-you-for things like host key confirmations. Running the local ssh instance with "-tt" causes it to request a PTY for the remote session. When it's non-interactive, it doesn't prompt the user for things like passwords and whether to accept a host key or not. In this case, the remote ssh instance sees that it's running without a TTY and runs non-interactively. When ssh is invoked with a command to run on the remote system, by default it runs that command without a TTY. Except that it's not prompting the user-it's just refusing to connect to the third host. So you'd normally expect ssh to prompt the user whether to continue connecting to the third host. ![]() The ssh instance doesn't have a saved copy of the third host's host key. In the case that you're describing, you're launching ssh on the remote system to connect to a third system. Try running ssh with the "-tt" option to request a PTY (pseudo-TTY) for the remote session: ssh -tt "REMOTE=yes HOSTNAME=$n $0 rm -f $0" After generating the key pairs using: ssh-keygen. ssh/authorizedkeys) will allow you to ssh from machineA. Having machineAs public key in machineBs authorized keys (i.e. What am I missing and how to make it work? If ssh-copy-id is not working, password authentication could be disabled. ssh/known_hosts file is present on a remote node so I can't do ssh-keygen -R. usr/bin/ssh-copy-id: ERROR: Host key verification failed.Īt that moment, no. usr/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed But the script that has just run successfully on the source node fails running in the remote ssh session: ssh-copy-id fails with the following error: /usr/bin/ssh-copy-id: INFO: Source of key(s) to be installed: "/home/username/.ssh/id_rsa.pub" When running on the source node, it works properly asking for a confirmation and the remote host's password. The user’s name and the script path are completely the same on the source node and all destination nodes. In row 14, I set and pass the variable REMOTE to skip the code block in rows 10-17 (so the script copies itself only from the source node to others), and the variable HOSTNAME because I found it’s not set in an ssh session. Then, if the REMOTE variable is not set, code in rows 11-16 copies the script to remote nodes (except the node it’s running on, row 12) and runs it there. The code in rows 6-8 works fine copying the ssh key to all nodes other than itself. Here’s the script: 1 #!/bin/bashĤ nodes=( main worker-01 worker-02 worker-03 )ġ4 ssh "REMOTE=yes HOSTNAME=$n $0 rm -f $0" What confuses me is the fact that ssh-copy-id works fine on the node where the script is executed manually but it fails if run remotely in an ssh session. ![]() For this, I wrote a simple bash script which copies itself to other nodes and runs it there. ![]() I have a task to copy ssh keys from one node to all others in an array. ![]()
0 Comments
Leave a Reply.AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |