Menu

SFTP with WinSCP and Auto Screen Capture

Setup SFTP Server (Linux)
Create a directory named "sftp_files" and change its mode to use 701 access permissions ...

mkdir -p /sftp_files
chmod 701 /sftp_files

Add a user group named "sftp_users", add a user named "sftpu" to that group with access to a directory named "upload", and give the user a password ...

groupadd sftp_users
useradd -g sftp_users -d /upload -s /sbin/nologin sftpu
passwd sftpu

(Choose a password at this point. I'm just going to use "password" as the password for this exercise).

Create the "upload" directory for the user and give access to the group ...

mkdir -p /sftp_files/sftpu/upload
chown -R root:sftp_users /sftp_files/sftpu
chown -R sftpu:sftp_users /sftp_files/sftpu/upload

Edit the SSH Daemon config file and add the appropriate statements such as Subsystem, Match Group, ChrootDirectory, and ForceCommand ...
vi /etc/ssh/sshd_config

The file should contain the following lines ...

Subsystem sftp internal-sftp
Match Group sftp_users
ChrootDirectory /sftp_files/%u
ForceCommand internal-sftp

Save the file and exit.

Start the SSH Daemon service ...
systemctl start sshd

(You can also use "stop" and "restart" commands).

To test the SFTP server simply login with the "sftp" command with localhost ...
sftp sftpu@localhost

You should see something like ...

sftpu@localhost's password: 
Connected to localhost.
sftp>

Test again with the name or IP address of your server ...
sftp sftpu@MYSERVER

Setup WinSCP
Download WinSCP from https://winscp.net/eng/download.php and install it on your Windows system.

Test your connection to the SFTP server by opening WinSCP and starting a session by logging into the server with ...
File protocol: SFTP
Host name: MYSERVER
Port number: 22
User name: sftpu
Password: password

Depending on where you've installed WinSCP make sure to include the path to WinSCP executable in your "Path" system environment variable. Mine is ...
C:\Users\gkendall\AppData\Local\Programs\WinSCP\

(This will give you access to the WinSCP application from anywhere in a Command Prompt or PowerShell terminal so you can simply execute "winscp").

Open a PowerShell terminal to test the connection to the SFTP server with WinSCP by giving a command like ...
winscp /command "open sftp://sftpu:password@MYSERVER/" "put C:\Users\gkendall\Desktop\screenshots\sftp_upload\MyScreenshot.jpeg MyScreenshot.jpeg" "exit"

(This is assuming you have a file named "MyScreenshot.jpeg" in "C:\Users\gkendall\Desktop\screenshots\sftp_upload\" to be uploaded by WinSCP).

Setup Auto Screen Capture
Open Auto Screen Capture (autoscreen.exe) and go to Change Screen of "Screen 1"
Make sure the folder is something you have access to. Mine is ...
C:\Users\gkendall\Desktop\screenshots\sftp_upload\
... and the value for Macro is simply something like "MyScreenshot.jpeg" so you end up with the full path to your screenshot as ...
C:\Users\gkendall\Desktop\screenshots\sftp_upload\MyScreenshot.jpeg

Go to the Editors module and add a new Editor setup like this ...
Name: WinSCP
Application: C:\Users\gkendall\AppData\Local\Programs\WinSCP\WinSCP.exe
Arguments: /command "open sftp://sftpu:password@MYSERVER/" "put $filepath$ MyScreenshot.jpeg" "exit"

Go to the Triggers module and add a new Trigger setup like this ...
Name: Take Screenshot and SFTP
Condition: Screenshot Taken
Action: Run Editor
Editor: WinSCP

Start a screen capture session with Auto Screen Capture (I think using a 1 minute interval is fine) and you should see a file named "MyScreenshot.jpeg" appear in the "/sftp_files/sftpu/upload" directory of your SFTP server.

Posted by Gavin Kendall 2020-11-03
  • Gavin Kendall

    Gavin Kendall - 2021-03-11

    Auto Screen Capture 2.3.4.0 introduced its own built-in SFTP feature so the steps described here with WinSCP are outdated by now, but it's still useful in case you want to know how to use an external application with my application.

     

    Last edit: Gavin Kendall 2021-03-11
    • John Keely

      John Keely - 2024-05-16

      Hello Gavin,

      I'm really sorry to bother you, however I've tried everything and for the life of me I cannot get the application to upload the screenshots via FTP. I have no trouble connecting using Filezilla (using regular ftp protocol NOT sftp) to the web host and I'm able to upload/download files at will. So the ftp server is up and running. However when I try to do a test upload within the screen capture application - I get a general "can't connect to server" error message.I'm probably doing something wrong, but I can't seem to figure it out. Any suggestions would be appreciated.

      Thanks,

      John

       
      • Gavin Kendall

        Gavin Kendall - 2024-05-16

        Make sure the port number is 21 for FTP. If the hostname (the domain) isn't working then try its IP address.

        Alternatively, if FileZilla has a command line way of uploading files, then you can add FileZilla as an Editor in Auto Screen Capture and provide the command line arguments there then add a Trigger to run the Editor whenever a screenshot is taken (as opposed to running a Trigger that's specifically for performing the FTP operation).

        If you're still having issues and want to share more detailed information feel free to private message me on SourceForge and I'll give you my personal email address so we can figure it out further.

         

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.