PSFTP Connection Automatically Closing: Keypress Issue
PSFTP (PuTTY Secure File Transfer Protocol) is a popular command-line tool used for secure file transfer over SSH. However, some users have reported an issue where the PSFTP window closes automatically after a keypress, making it difficult to transfer files.
Understanding the Issue
The issue occurs when the connection times out, or the server automatically closes the connection after a certain period of inactivity. This is a security feature implemented by the server to prevent unauthorized access. However, it can be frustrating for users who are trying to transfer files.
Preventing the Connection from Closing
One way to prevent the connection from closing is to keep sending data periodically. This can be done by setting up a script that sends a command to the server at regular intervals. Here's an example of how to do this using a batch file:
echo open servername
echo user username
echo password
psftp.exe -b batchfile.txt
In this example, the batchfile.txt contains the commands to be executed on the server. By sending a command to the server at regular intervals, the connection is kept active, and the issue of the PSFTP window closing after a keypress is avoided.
Configuring PSFTP to Prevent Connection Closure
Another way to prevent the connection from closing is to configure PSFTP to send a command to the server periodically. This can be done using the set command. Here's an example:
set timeout=600
set keepalives 300
open servername
user username
password
psftp.exe
In this example, the set timeout command sets the timeout value to 600 seconds, while the set keepalives command sends a command to the server every 300 seconds to keep the connection active. This prevents the connection from closing due to inactivity.
References
- PuTTY documentation: https://www.putty.org/
- PSFTP manual: https://the.earth.li/~sgtatham/putty/0.78/htmldoc/Chapter7.html#psftp
- SSH keepalives: https://www.ssh.com/ssh/keepalives/
By following the steps outlined in this article, you can prevent the PSFTP window from closing after a keypress due to connection timeout or server inactivity. This will make it easier to transfer files using PSFTP.