{"id":29927602,"url":"https://github.com/grymmjack/greenshot-powershell-uploader","last_synced_at":"2025-08-02T13:12:00.376Z","repository":{"id":305580249,"uuid":"1023251636","full_name":"grymmjack/greenshot-powershell-uploader","owner":"grymmjack","description":"Custom powershell script using pscp (PuTTY) to upload screenshots to sftp server for greenshot","archived":false,"fork":false,"pushed_at":"2025-07-20T21:47:08.000Z","size":14,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-07-20T23:31:37.285Z","etag":null,"topics":["greenshot","powershell","putty","screenshot-uploader","screenshot-utility","windows-greenshot-upload-to-server"],"latest_commit_sha":null,"homepage":"","language":"PowerShell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/grymmjack.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":"AUTHORS.md","dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-07-20T21:00:46.000Z","updated_at":"2025-07-20T21:47:11.000Z","dependencies_parsed_at":"2025-07-20T23:31:39.633Z","dependency_job_id":"211abe5e-0ead-4bb7-8d14-e05643022ceb","html_url":"https://github.com/grymmjack/greenshot-powershell-uploader","commit_stats":null,"previous_names":["grymmjack/greenshot-powershell-uploader"],"tags_count":null,"template":false,"template_full_name":null,"purl":"pkg:github/grymmjack/greenshot-powershell-uploader","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/grymmjack%2Fgreenshot-powershell-uploader","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/grymmjack%2Fgreenshot-powershell-uploader/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/grymmjack%2Fgreenshot-powershell-uploader/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/grymmjack%2Fgreenshot-powershell-uploader/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/grymmjack","download_url":"https://codeload.github.com/grymmjack/greenshot-powershell-uploader/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/grymmjack%2Fgreenshot-powershell-uploader/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":268394203,"owners_count":24243381,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-08-02T02:00:12.353Z","response_time":74,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["greenshot","powershell","putty","screenshot-uploader","screenshot-utility","windows-greenshot-upload-to-server"],"created_at":"2025-08-02T13:11:50.979Z","updated_at":"2025-08-02T13:12:00.364Z","avatar_url":"https://github.com/grymmjack.png","language":"PowerShell","funding_links":[],"categories":[],"sub_categories":[],"readme":"# PowerShell Upload Script Configuration Guide\n\nThis guide explains how to configure the `upload-and-copy.ps1` script for your own environment.\n\n\u003e **📝 Note**: Throughout this guide, replace `username` with your actual Windows username (e.g., if your user folder is `C:\\Users\\john`, replace `username` with `john`).\n\n## �️ Tested Environment\n\nThis script and configuration guide has been tested and verified on the following environment:\n\n| Component | Version | Notes |\n|-----------|---------|-------|\n| **Windows** | Windows 11 24H2 (Build 26100.4652) | Should work on Windows 10/11 |\n| **PowerShell** | 5.1.26100.4652 | Built-in Windows PowerShell |\n| **PuTTY Suite** | 0.83 | Includes PuTTY, PSCP, Pageant, PuTTYgen |\n| **Greenshot** | v1.2.10 | Screenshot and annotation tool |\n\n### 🚀 Quick Installation (Advanced Users)\n\nFor advanced users, you can install PuTTY using Windows Package Manager:\n```cmd\nwinget install putty.putty\n```\n\nFor regular installation, download from the official sources listed in the setup steps below.\n\n## �📋 Configuration Variables\n\nEdit the configuration section at the top of `upload-and-copy.ps1` to match your setup:\n\n### 🌐 Upload Server Configuration\n\n```powershell\n$UPLOAD_USERNAME = \"your-ssh-username\"     # SSH username for your server\n$UPLOAD_SERVER = \"your-domain.com\"         # Your server hostname/IP\n$UPLOAD_REMOTE_DIR = \"/path/to/upload/\"    # Remote directory (must end with /)\n$PUTTY_PROFILE = \"your-profile-name\"       # PuTTY session profile name\n```\n\n**Examples:**\n- **Username**: `root`, `ubuntu`, `www-data`, `your-username`\n- **Server**: `example.com`, `192.168.1.100`, `files.mysite.org`\n- **Remote Dir**: `/var/www/html/uploads/`, `/home/user/public/`, `/srv/files/`\n- **Profile**: `myserver`, `webhost`, `production`\n\n### 💻 Local System Configuration\n\n```powershell\n$PSCP_PATH = \"C:\\Program Files\\PuTTY\\pscp.exe\"\n```\n\n**Common PuTTY installation paths:**\n- Default: `C:\\Program Files\\PuTTY\\pscp.exe`\n- 32-bit on 64-bit: `C:\\Program Files (x86)\\PuTTY\\pscp.exe`\n- Portable: `C:\\Tools\\PuTTY\\pscp.exe`\n- Chocolatey: `C:\\ProgramData\\chocolatey\\bin\\pscp.exe`\n\n### 🔗 Public URL Configuration\n\n```powershell\n$PUBLIC_BASE_URL = \"https://your-domain.com/uploads\"\n```\n\nThis should be the web-accessible URL that corresponds to your `$UPLOAD_REMOTE_DIR`.\n\n**Mapping Examples:**\n- Remote: `/var/www/html/uploads/` → URL: `https://mysite.com/uploads`\n- Remote: `/var/www/html/files/` → URL: `https://mysite.com/files`\n- Remote: `/srv/nginx/static/` → URL: `https://cdn.mysite.com`\n\n### 📝 Logging Configuration\n\n```powershell\n$CUSTOM_SUCCESS_LOG = \"\"  # Leave empty for default location\n$CUSTOM_ERROR_LOG = \"\"    # Leave empty for default location\n```\n\n**Default locations:**\n- Success: `%USERPROFILE%\\pscp_upload_success.log`\n- Error: `%USERPROFILE%\\pscp_upload_errors.log`\n\n**Custom examples:**\n- `\"C:\\Logs\\upload_success.log\"`\n- `\"D:\\MyApp\\Logs\\upload_errors.log\"`\n- `\"\\\\NetworkShare\\Logs\\upload.log\"`\n\n## 🔧 Setup Steps\n\n### 1. Install PuTTY\n\n**Option A: Official Download (Recommended for most users)**\nDownload from: https://www.putty.org/\n\n**Option B: Windows Package Manager (Advanced users)**\n```cmd\nwinget install putty.putty\n```\n\nThis installs the complete PuTTY suite including PuTTY, PSCP, Pageant, and PuTTYgen.\n\n### 2. File Placement and Directory Setup\n\n**Create a dedicated directory for the upload scripts:**\n```cmd\nmkdir C:\\Users\\username\\bin\n```\n(Replace `username` with your actual Windows username)\n\n**Copy both script files to the same directory:**\n- `upload-and-copy.ps1` (PowerShell script)\n- `upload-wrapper.bat` (Batch wrapper)\n\n\u003e **⚠️ Important**: The `.bat` and `.ps1` files must be in the same directory. The batch file uses relative path references (`%~dp0`) to locate the PowerShell script, so they cannot be separated.\n\n**Example directory structure:**\n```\nC:\\Users\\username\\bin\\\n├── upload-and-copy.ps1\n└── upload-wrapper.bat\n```\n\n### 3. SSH Key Setup and PuTTY Session Configuration\n\n#### 3a. Generate SSH Key Pair\n1. Open **PuTTYgen** (installed with PuTTY)\n2. Select **RSA** key type and set **Number of bits** to **2048** or **4096**\n3. Click **Generate** and move your mouse randomly to create entropy\n4. Once generated:\n   - **Key comment**: Enter a descriptive name (e.g., `yourusername@hostname-upload-key` - replace with your actual username and server)\n   - **Key passphrase**: Enter a secure passphrase (optional but recommended)\n5. **Save the private key**: Click **Save private key** → Save as `upload-key.ppk` in a secure location\n6. **Copy the public key**: Select all text in the \"Public key for pasting...\" box and copy it\n\n#### 3b. Install Public Key on Server\n1. Connect to your server via SSH using existing credentials (password or existing key)\n2. Create SSH directory: `mkdir -p ~/.ssh \u0026\u0026 chmod 700 ~/.ssh`\n3. Add your public key: `echo \"YOUR_PUBLIC_KEY_HERE\" \u003e\u003e ~/.ssh/authorized_keys`\n4. Set permissions: `chmod 600 ~/.ssh/authorized_keys`\n\n**Note**: Replace `YOUR_PUBLIC_KEY_HERE` with the actual public key text you copied from PuTTYgen.\n\n#### 3c. Configure Pageant (SSH Agent)\n1. **Add Pageant to Windows Startup**:\n   - Press `Win + R`, type `shell:startup`, press Enter\n   - Create a shortcut to `pageant.exe` (usually in `C:\\Program Files\\PuTTY\\`)\n   - Right-click shortcut → **Properties** → **Target**: \n     ```\n     \"C:\\Program Files\\PuTTY\\pageant.exe\" \"C:\\Path\\To\\Your\\upload-key.ppk\"\n     ```\n   - This will auto-load your key on Windows startup\n\n2. **Start Pageant Now**:\n   - Run the command above manually or double-click the shortcut\n   - Enter your key passphrase when prompted\n   - Pageant will run in the system tray\n\n#### 3d. Create PuTTY Session Profile\n1. **Open PuTTY**\n2. **Basic Connection Settings**:\n   - **Host Name**: Enter your server hostname or IP (e.g., `your-server.com`)\n   - **Port**: `22` (default SSH port)\n   - **Connection type**: `SSH`\n\n3. **Configure SSH Authentication**:\n   - Navigate to **Connection** → **SSH** → **Auth** → **Credentials**\n   - **Private key file**: Browse and select your `upload-key.ppk` file\n   - ✅ Check **Allow agent forwarding** (optional)\n   - ✅ Check **Allow attempted changes of username in SSH-2**\n\n4. **Auto-login Configuration**:\n   - Navigate to **Connection** → **Data**\n   - **Auto-login username**: Enter your SSH username (e.g., `root`, `ubuntu`, `www-data`)\n\n5. **Session Settings**:\n   - Navigate back to **Session** (top of tree)\n   - **Saved Sessions**: Enter a memorable name (e.g., `YourServerPuttySession`, `linode`, `webserver`)\n   - Click **Save** to store the session\n\n6. **Test the Connection**:\n   - With your session selected, click **Open**\n   - Should connect without password prompt (using SSH key)\n   - If prompted for passphrase, ensure Pageant is running with your key loaded\n\n#### 3e. Update Script Configuration\nEdit your `$PUTTY_PROFILE` variable to match your saved session name:\n```powershell\n$PUTTY_PROFILE = \"YourServerPuttySession\"  # Match your saved PuTTY session name\n```\n\n**Example configurations:**\n- `$PUTTY_PROFILE = \"linode\"`\n- `$PUTTY_PROFILE = \"webserver\"`\n- `$PUTTY_PROFILE = \"production\"`\n\n### 4. Configure Script Variables\nEdit the configuration section in `upload-and-copy.ps1` with your values.\n\n### 5. Test the Script\n```powershell\n.\\upload-and-copy.ps1 \"C:\\path\\to\\test-file.png\"\n```\n\n### 6. Configure Greenshot Integration (Optional)\n\n#### Step 6a: Install External Command Plugin\n1. Open Greenshot\n2. Go to **Settings** (right-click Greenshot tray icon → Configure)\n3. Navigate to **Plugins** tab\n4. If \"External command Plugin\" is not listed, install it:\n   - Download from Greenshot plugins repository\n   - Place the plugin DLL in Greenshot's plugins folder\n   - Restart Greenshot\n\n#### Step 6b: Configure External Command\n1. In Greenshot Settings, go to **Plugins** tab\n2. Select **External command Plugin** and click **Configure**\n3. Click **New** to create a new command\n4. Enter the following settings:\n\n**Command Configuration:**\n- **Name**: `Upload to your-domain.com` (customize as needed)\n- **Command**: `C:\\Users\\username\\bin\\upload-wrapper.bat` (replace `username` with your Windows username)\n- **Argument**: `{0}`\n\n**Alternative PowerShell Direct Method:**\n- **Name**: `Upload to your-domain.com`\n- **Command**: `C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe`\n- **Argument**: `-NoProfile -STA -ExecutionPolicy Bypass -File \"C:\\Users\\username\\bin\\upload-and-copy.ps1\" \"{0}\"` (replace `username` with your Windows username)\n\n5. Click **OK** to save the command\n6. Click **OK** to close External command settings\n7. Click **OK** to close Greenshot settings\n\n#### Step 6c: Using the Upload Command\n1. Take a screenshot with Greenshot (PrtScn, region select, etc.)\n2. In the Greenshot editor, look for your custom command in the toolbar or **File** menu\n3. Click your \"Upload to your-domain.com\" command\n4. The rename dialog will appear - enter desired filename\n5. File uploads automatically and URL is copied to clipboard\n\n#### Alternative: Quick Upload Shortcut\nYou can also create a desktop shortcut for quick manual uploads:\n\n**Target**: `C:\\Users\\username\\bin\\upload-wrapper.bat` (replace `username` with your Windows username)\n**Start in**: `C:\\Users\\username\\bin\\` (replace `username` with your Windows username)\n\nThen drag any file onto the shortcut to upload it.\n\n## 🚨 Troubleshooting\n\n### Common Issues:\n\n**\"pscp.exe not found\"**\n- Check `$PSCP_PATH` points to correct PuTTY installation\n- Install PuTTY if missing\n\n**\"Connection failed\"**\n- Verify `$PUTTY_PROFILE` name matches saved session\n- Test SSH connection manually with PuTTY\n- Check firewall/network connectivity\n\n**\"Permission denied\"**\n- Verify `$UPLOAD_USERNAME` has write access to `$UPLOAD_REMOTE_DIR`\n- Check SSH key permissions\n\n**\"File not accessible via URL\"**\n- Verify `$PUBLIC_BASE_URL` matches web server configuration\n- Check web server permissions on upload directory\n- Ensure directory is in web server document root\n\n### SSH Key \u0026 Authentication Issues:\n\n**\"Server refused our key\" or \"Authentication failed\"**\n- Verify public key is properly installed in `~/.ssh/authorized_keys` on server\n- Check file permissions: `chmod 600 ~/.ssh/authorized_keys` and `chmod 700 ~/.ssh`\n- Ensure private key file path is correct in PuTTY session configuration\n- Test key manually: open PuTTY session and verify passwordless login works\n\n**\"Unable to use key file\" or \"Couldn't load private key\"**\n- Verify `.ppk` file exists and is accessible\n- Check if key file is corrupted - regenerate if necessary\n- Ensure key was saved in PuTTY format (`.ppk`), not OpenSSH format\n\n**\"No supported authentication methods available\"**\n- Server may not allow SSH key authentication\n- Check server's `/etc/ssh/sshd_config` for `PubkeyAuthentication yes`\n- Verify `AuthorizedKeysFile` setting points to correct location\n\n**Pageant Issues:**\n- **\"Agent refused to sign\"**: Restart Pageant and reload your key\n- **Key not auto-loading**: Check Pageant startup shortcut target path\n- **Passphrase keeps prompting**: Verify Pageant is running with your key loaded\n- **Multiple keys conflict**: Use `pageant.exe -c \"your-command\"` to clear all keys first\n\n**PuTTY Session Configuration Issues:**\n- **Wrong username**: Verify **Connection** → **Data** → **Auto-login username** matches server\n- **Wrong hostname**: Double-check **Session** → **Host Name** field\n- **Session not found**: Verify `$PUTTY_PROFILE` exactly matches saved session name (case-sensitive)\n- **Key not loading**: Check **Connection** → **SSH** → **Auth** → **Credentials** → **Private key file**\n\n### Greenshot Integration Issues:\n- **Command not appearing**: Restart Greenshot after plugin installation\n- **\"File not found\" error**: Verify paths in External Command configuration\n- **PowerShell execution policy**: Run `Set-ExecutionPolicy RemoteSigned` as Administrator\n- **Upload dialog not showing**: Ensure `-STA` parameter is included for PowerShell command\n\n## 📖 Example Configurations\n\n### Example 1: Standard Web Server\n```powershell\n$UPLOAD_USERNAME = \"www-data\"\n$UPLOAD_SERVER = \"mywebsite.com\"\n$UPLOAD_REMOTE_DIR = \"/var/www/html/uploads/\"\n$PUTTY_PROFILE = \"webserver\"\n$PUBLIC_BASE_URL = \"https://mywebsite.com/uploads\"\n```\n\n### Example 2: Personal VPS\n```powershell\n$UPLOAD_USERNAME = \"ubuntu\"\n$UPLOAD_SERVER = \"192.168.1.50\"\n$UPLOAD_REMOTE_DIR = \"/home/ubuntu/public_html/files/\"\n$PUTTY_PROFILE = \"homeserver\"\n$PUBLIC_BASE_URL = \"https://files.home.local\"\n```\n\n### Example 3: CDN/Static File Server\n```powershell\n$UPLOAD_USERNAME = \"deploy\"\n$UPLOAD_SERVER = \"cdn.company.com\"\n$UPLOAD_REMOTE_DIR = \"/srv/nginx/static/uploads/\"\n$PUTTY_PROFILE = \"cdn-server\"\n$PUBLIC_BASE_URL = \"https://static.company.com/uploads\"\n```\n\n## 📸 Greenshot Quick Reference\n\n### External Command Plugin Settings\nBased on the screenshots provided, here's the exact configuration:\n\n**In Greenshot Settings → Plugins → External command Plugin → Configure:**\n\n| Field | Value |\n|-------|-------|\n| **Name** | `Upload to share.username.com` (replace `username` with your domain) |\n| **Command** | `C:\\Users\\username\\bin\\upload-wrapper.bat` (replace `username` with your Windows username) |\n| **Argument** | `{0}` |\n\n**Alternative PowerShell Direct:**\n| Field | Value |\n|-------|-------|\n| **Command** | `C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe` |\n| **Argument** | `-NoProfile -STA -ExecutionPolicy Bypass -File \"C:\\Users\\username\\bin\\upload-and-copy.ps1\" \"{0}\"` (replace `username` with your Windows username) |\n\n### Usage Workflow\n1. **Capture** → Take screenshot with Greenshot\n2. **Edit** → Make any needed edits in Greenshot editor  \n3. **Upload** → Click your custom \"Upload to...\" command\n4. **Rename** → Enter filename in dialog that appears\n5. **Share** → URL is automatically copied to clipboard\n\n### Tips\n- The `{0}` argument passes the screenshot file path to your script\n- Use the batch wrapper for simpler configuration\n- Use direct PowerShell method for more control\n- Customize the \"Name\" field to match your domain/service\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgrymmjack%2Fgreenshot-powershell-uploader","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgrymmjack%2Fgreenshot-powershell-uploader","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgrymmjack%2Fgreenshot-powershell-uploader/lists"}