1

I'm working on a project where I have to run a python script which will open a tmux session with multiple windows, in each one ssh into a different remote machine, and run another python script. I'm new to both tmux and ssh and I was using VS Code's built in terminal, which worked fine, up until I wanted to clear the tmux server. I manually ran tmux kill-server to get rid of all the sessions and windows I had created. Upon running my python script again, I noticed that it hadn't given an output like it usually did. I attached to the tmux session and I saw that when the script had tried to ssh onto the remote machine the terminal had returned:

could not open any host key
ssh_keysign: no reply
sign using hostkey ssh-ed25519 SHA256:/BRoTCDFKguzQMzgzvdPa48k3sm6k9J9WWgmc/ly39U failed
(<user>) Password: 

and then prompts you for your password.
This wouldn't be a problem if I was SSHing into the remote machine manually, but I have a python script that runs

set_up_file_command = f'tmux send-keys -t {session_name} -l "ssh {cpu_name} python {file_path} {cpu_name}"'
subprocess.run(set_up_file_command, shell=True)

I can probably change the script to accommodate a password but I'm interested in why clearing the tmux server to begin with created this issue and why a normal terminal works. When I ssh into the remote machine through a normally opened terminal all I have to do is ssh <machine_name>, without specifying a password.

I've tried restarting the integrated terminal and restarting the tmux server several times but nothing has changed. I'm very inexperienced when it comes to ssh, tmux, and server work and I'm pretty lost. I can use the regular terminal to run my python script but I just want to know why it doesn't work in the integrated terminal?

5
  • Please compare the output of ls -l "$HOME"/.ssh when run in your normal interactive context, and then the context of the tmux command. (You may need to create a snippet of Python that calls this command instead of calling tmux. If so, make sure you set up the environment, etc., exactly as for your real program.) Commented Jun 20 at 16:24
  • Chris, it's complaining about the HOST keys, as if it couldn't access /etc/ssh/ssh_host* .. it's unclear to me,given the set-up, whether that's on the local machine or on the far end.
    – tink
    Commented Jun 20 at 16:30
  • 1
    @tink thanks. I saw that and wondered if the machines really were relying on host keys. But unless there's a chroot (or namespace) involved I couldn't see how that would be relevant between the two different approaches to authentication. Perhaps there's more to the story - like one being a systemd service unit, but until I get enough of a handle to ask directed questions I'm trying a process of elimination Commented Jun 20 at 17:57
  • @ChrisDavies Ok, when I ran ls -l "$HOME"/.ssh both manually and through a python script(through the normal terminal) I get total 0. But when I do both through VS Code's integrated terminal, manually running it gets the same thing, total 0, but when I run it through the python script and attach to the session, there is no output, like the command ran but nothing printed in the terminal. I am pretty sure I made the environment the same. Thanks for the help!
    – a dude
    Commented Jun 21 at 22:59
  • Thank you. I'll have another think tomorrow Commented Jun 21 at 23:45

0

You must log in to answer this question.

Browse other questions tagged .