Hier noch eine Version, bei der man den Dateinamen (inclusive des vollen Pfades z.b. /home/testuser/meinedatei.txt )
angibt, und dann auch den Text in der Eingabe angibt.
Mit Strg+D speichert und beendet man die Eingabe.
#!/bin/bash
# Get the IP address, username, ssh key path, and file name
echo "Enter the IP address of your VPS:"
read vps_ip
echo "Enter the username:"
read username
echo "Enter the path to your ssh key:"
read ssh_key
echo "Enter the name of the file:"
read file_name
# Connect to the VPS using ssh and key-based authentication
ssh -i .ssh/$ssh_key $username@$vps_ip << EOF
# Run the curl command to install rclone
curl https://rclone.org/install.sh | sudo bash
# Create a file with the specified content
cat > $file_name
EOF
# Input the file content after connecting to the VPS
echo "Enter the content of the file, followed by [CTRL]+[D] to save and exit:"
cat | ssh -i .ssh/$ssh_key $username@$vps_ip "cat >> $file_name"