from pyinfra.operations import ssh
# Add a host to known_hosts
ssh.keyscan(
name="Set add server two to known_hosts on one",
hostname="two.example.com",
)
# Execute a command on another server
ssh.command(
name="Create file by running echo from host one to host two",
hostname="two.example.com",
command="echo 'one was here' > /tmp/one.txt",
user="vagrant",
)
# Upload a file to another server
ssh.upload(
name="Upload file to another server",
hostname="two.example.com",
filename="/tmp/myfile.txt",
remote_filename="/tmp/remote_file.txt",
)