Sharing WinSCP Configurations – DZone DevOps

You could have skilled the scenario that an skilled workforce member, geared up with a lot of configured WinSCP websites, wish to share this info with a beginner workforce member (and all future newbies). A easy export & import won’t suffice, for the reason that configuration comprises personalised authentication knowledge (usernames and passwords, or keyfile places). And also you don’t wish to power the beginner to manually copy-and-paste connection knowledge and his personal authentication knowledge right into a sequence of recent WinSCP websites, as this might be inefficient, tedious, and error-prone.

Resolution (Overview)

Here’s a fast overview of the answer to this downside. Particulars might be given within the sections under.

Export and de-customization of the present configuration:

  • Group websites with equivalent authentication knowledge into WinSCP folders
  • Export the configuration into an ini file utilizing the suitable WinSCP dialog
  • De-customize this configuration by way of command line (reset credentials & working directories)
  • Do some clean-up on the ini file (historical past)
  • Share the ini file with the beginner (e.g., by committing it to your workforce’s SCM)

Customization and import of this configuration:

  • Retrieve the ini file
  • Customise this configuration by way of command line (set credentials & working directories)
  • Launch WinSCP with this configuration

Resolution (Particulars)

Grouping

When utilizing a central LDAP server for authentication, most of your logins would require the identical credentials. On the identical time, there may be logins with particular credentials (resembling read-only “view” customers for sure check servers) that don’t require customization, and that shall be left untouched. To permit the beginner to customise the fitting websites with a single batch script, it’s a must to group them utilizing WinSCP folders. This may be accomplished inside WinSCP by selecting Handle > New Folder:

Right here is an easy instance how your WinSCP structure would possibly appear like:

This scheme will be simply prolonged to cowl a number of private customers, and mixed with sub-folders for managing totally different tasks.

Export

Export the configuration by selecting Instruments > Export/Backup Configuration inside WinSCP:

De-Customization

On this step, you overwrite personalised knowledge from the exported configuration with generic default values:

  • person names
  • key file places
  • working directories

That is accomplished by executing the next script:

@echo off

REM configuration settings used under
set YOUR_INI="demo.ini"
set YOUR_LDAP_USER="ldapuser"
set YOUR_WINDOWS_USER="winuser"
set YOUR_PRIVATE_KEY="C:UsersYouprivatekey.ppk"
set WINSCP_DIR="C:Program Recordsdata (x86)WinSCP"

REM adapt login credentials
%WINSCP_DIRpercentWinSCP.com ^
  /ini=%YOUR_INI% ^
  /batchsettings ^
  "Private Consumer"/* ^
  UserName=%YOUR_LDAP_USER% ^
  TunnelUserName=%YOUR_LDAP_USER% ^
  PublicKeyFile=%YOUR_PRIVATE_KEY% ^
  TunnelPublicKeyFile=%YOUR_PRIVATE_KEY%"

REM adapt working directories
%WINSCP_DIRpercentWinSCP.com ^
  /ini=%YOUR_INI% ^
  /batchsettings ^
  */* ^
  LocalDirectory="C:UserspercentYOUR_WINDOWS_USER%" ^
  RemoteDirectory=/

So what is occurring right here?

  • /ini supplies the situation of your exported ini file
  • /batchsettings permits mass-modification of saved websites
  • Private Consumer/* and */* match the location configurations inside the present folders
  • UserName and TunnelUserName are self-explanatory
  • PublicKeyFile and TunnelPublicKeyFile present the situation of your personal SSH key file
  • LocalDirectory and RemoteDirectory present the directories which might be opened by WinSCP after login

Observe that we use WinSCP.com as a substitute of WinSCP.exe for scripting.

If you’re working with passwords as a substitute of key recordsdata, it’s a must to present the PasswordPlain parameter to reset your passwords. Nonetheless, this solely works in case you first disable your WinSCP grasp password, so watch out when doing this.

Cleanup

The exported ini file comprises a number of strains of utilization historical past that you could simply clear up with a textual content editor. Merely seek for the next part headers, and delete the strains under:

  • [ConfigurationHistoryCommands]
  • [ConfigurationHistoryEditFile]
  • [ConfigurationHistoryLocalTarget]
  • [ConfigurationHistoryPuttyPath]
  • [ConfigurationHistoryRemoteTarget]

To just remember to didn’t miss something, you possibly can manually double-check the values saved within the config file, and seek for your person title and the string go.

Launching with a particular config

The personalized ini file will be offered as a command-line parameter to WinSCP:

%WINSCP_DIRpercentWinSCP.exe /ini=demo.ini

This fashion, you may also set up your websites into a number of recordsdata, and create acceptable shortcuts for on-demand use.

References

WinSCP model used for this text: 5.17


Supply hyperlink

About PARTH SHAH

Check Also

मंत्री मुकेश सहनी बोले- पर्दे के पीछे से हो रहा ‘खेल’, VIP विधायकों को गुमराह करने की कोशिश जारी

पटना: बिहार सरकार में मंत्री मुकेश सहनी के एनडीए की बैठक का बहिष्कार करने के …

Leave a Reply

Your email address will not be published. Required fields are marked *

x