nixos/tests/tmate-ssh-server: fix test

- add `wait_until_tty_matches` to wait for tty login screen before
sending "root\n" to log in
- add `-4` to `ssh-keyscan` to force using IPv4, without it command
returns exit code 1 with no output
This commit is contained in:
ghpzin 2024-09-16 17:06:38 +03:00
parent a19858044e
commit 65feac8311
No known key found for this signature in database

View File

@ -52,6 +52,7 @@ in
server.succeed("scp ${sshOpts} /tmp/tmate.conf client:/tmp/tmate.conf")
client.wait_for_file("/tmp/tmate.conf")
client.wait_until_tty_matches("1", "login:")
client.send_chars("root\n")
client.sleep(2)
client.send_chars("tmate -f /tmp/tmate.conf\n")
@ -62,7 +63,8 @@ in
client.wait_for_file("/tmp/ssh_command")
ssh_cmd = client.succeed("cat /tmp/ssh_command")
client2.succeed("mkdir -p ~/.ssh; ssh-keyscan -p 2223 server > ~/.ssh/known_hosts")
client2.succeed("mkdir -p ~/.ssh; ssh-keyscan -4 -p 2223 server > ~/.ssh/known_hosts")
client2.wait_until_tty_matches("1", "login:")
client2.send_chars("root\n")
client2.sleep(2)
client2.send_chars(ssh_cmd.strip() + "\n")