Expect not working inside my Bash script

I am trying to execute expect command inside by small bash script to login into servers using key authentication method. My script is as follows:

#!/bin/bash
HOST=$1
/usr/bin/expect -c "
                    spawn ssh -i /root/.ssh/id_rsa root@$HOST  
                    expect -exact "Enter passphrase for key '/root/.ssh/id_rsa': " ;
                    send "PASSPHRASE\n" ; 
                    interact
                   "

Output with error is: :rolleyes:

spawn ssh -i /root/.ssh/id_rsa root@server.domain.com
couldn't read file "passphrase": no such file or directory

Can you help to correct this? :confused:

What system are you working on?
To me it 'works' as in.... i get spamed, line after line, by 'y' after adding the hosts to known (asked by ssh).

I did change /root to $HOME though...

I am running it in Ubuntu

I get the impression that management crossed their wires somewhere and handed you contradictory requirements, because the utter futility of bruteforcing interactive plaintext passwords into an ssh key is quite glorious.

I would suggest ssh-agent instead. Type the password in securely and once, and your session will remember it for as long as it's open, without embedding the password in a script for everyone to read. Because this is using the system as it's intended to be used, you do not need to install the third-party brute-forcing utility expect to do so.

Or just removing the password from the key.