I'm looking for a way to import a ldif file into a apacheDS 2.0 LDAP server. I've seen there was a way with 1.5 and the apacheds-tools.jar but this seems to be removed.
Is there another easy way to get the task done?
You can use Apache Directory Studio for this.
Just start it, connect to your directory, right-click on "Root DSE" or any other element of the directory and choose "Import" -> "LDFI import".
It is also described here: https://directory.apache.org/apacheds/basic-ug/2.1.1-adding-entries.html
To get the required tools for windows, your can install OpenLDAP (you can get it here: http://www.userbooster.de/en/download/openldap-for-windows.aspx), the client tools contain a ldapmodify.exe (in \OpenLDAP\ClientTools\).
To use the command line tools on linux you need to install the package ldap-utils (apt-get install ldap-utils).
Then you can do the following:
ldapmodify -h hostname -p 10389 -D "uid=admin,ou=system" -w adminpassword -a -f your-file.ldif
Replace:
hostname with hostname
10389 with the port on which your directory server is running
"uid=admin,ou=system" with the DN of the (probably admin) user you want to use for connecting
10389 with the password of the user
your-file.ldif with the path of your ldif file
For more information, you can have a look at this: https://cwiki.apache.org/confluence/display/DIRxSRVx10/2.2.2.+Command+line+tools
Related
I have installed windows subsystem for Linux to run Ubuntu 16.04 on my windows 10 home platform.
I have extracted all required directories to run KSQL on this platform.
Now, when I am trying to run any command after navigating to the bin folder. It's throwing command not found error. I tried to add PATH as well but it's not working.
Please suggest.
There's a typo in your command:
export PATH=$PATH:/opt/kafka/confleuent-5.4.0/bin
Instead of confluent-5.4.0 you misspelled it confleuent-5.4.0.
The easiest way to install Confluent CLI, is by making use of the scripted installation:
Install the Confluent CLI using this script. This command creates a
bin directory in your designated location (<path-to-directory>/bin).
The location must be in your PATH (e.g. /usr/local/bin). On Microsoft
Windows, an appropriate Linux environment may need to be installed in
order to have the curl and sh commands available, such as the Windows
Subsystem for Linux
curl -L https://cnfl.io/cli | sh -s -- -b /<path-to-directory>/bin
Finally, if you run confluent start you can get all services up and running, including KSQL (assuming that you have correct configuration files).
You could just use the path
cd bin
./kafka-topics.sh
Also, all those commands work in CMD / PowerShell as well
If you want to run KSQL, I'd suggest just using Docker
I need to write a script that transfers files from a folder onto another server (Linux), but the script that's transferring files is on windows, and I was wondering if there was an alternative to scp for PowerShell (or if there was another way of doing this)
There is a handy little tool that comes with Putty called pscp.exe that will do this and can be called in powershell easily.
Example below copies from windows to a CentOS box (logging in as the usercode "bill") and you use the -pw switch in pscp to pass in a password (otherwise the command window that is spawned will prompt for the Linux password):
Start-Process 'C:\Program Files (x86)\PuTTY\pscp.exe' -ArgumentList ("-scp -pw password C:\Document.rtf bill#192.168.0.28:/home/bill/")
PuTTY Secure Copy client
Release 0.62
Usage: pscp [options] [user#]host:source target
pscp [options] source [source...] [user#]host:target
pscp [options] -ls [user#]host:filespec
Options:
-V print version information and exit
-pgpfp print PGP key fingerprints and exit
-p preserve file attributes
-q quiet, don't show statistics
-r copy directories recursively
-v show verbose messages
-load sessname Load settings from saved session
-P port connect to specified port
-l user connect with specified username
-pw passw login with specified password
-1 -2 force use of particular SSH protocol version
-4 -6 force use of IPv4 or IPv6
-C enable compression
-i key private key file for authentication
-noagent disable use of Pageant
-agent enable use of Pageant
-batch disable all interactive prompts
-unsafe allow server-side wildcards (DANGEROUS)
-sftp force use of SFTP protocol
-scp force use of SCP protocol
pscp.exe is a viable option, but I have been using a library from Rebex for a couple years now for SFTP and FTPS transfers in both C# apps and PowerShell scripts with great success. Their package also includes an SCP object but I haven't personally used it.
It does cost money vs. pscp being free. Before selecting the Rebex package, I had considered going the PuTTY route but my team decided that having a library we could easily roll into any app/script was worthwhile in the long term.
You can use WinSCP .NET assembly from PowerShell for SCP transfers.
For example see http://winscp.net/eng/docs/library_powershell#example
The example uses SFTP protocol. To use SCP, just modify it to:
$sessionOptions.Protocol = [WinSCP.Protocol]::Scp
Though if your server support SCP protocol, it's likely it also supports SFTP. SFTP is better choice, if you have the option.
Why use an alternative to SCP when you can use SCP?
Windows has OpenSSH (which includes SCP) as an optional component these days, so you could just use that. It first appeared in the Autumn 2018 version of Windows 10. It's nearly identical to the command you find in most Linux distributions, as it's derived from the same code base. Microsoft just made one or two minor tweaks to make it work on windows.
It is simple to install just go to Start->Settings->Apps->Optional Features->View Features enter in OpenSSH in the search box and check the OpenSSH client and click next. See OpenSSH in Windows for more detailed instructions on how to set it up. For a more PowerShell way of installing it run this from an elevated PowerShell prompt:
Add-WindowsCapability -Online -Name OpenSSH.Client~~~~0.0.1.0
You can use this command to check if there is a newer version and whether you already have it installed:
Get-WindowsCapability -Online | Where Name -Like '*ssh*'
Once installed, you call scp from PowerShell just like you would any other executable command.
scp file.dat user.name#example.com:/target/path
If you really don't want to use SCP use Copy-Item
This requires PowerShell to be installed on your server. Yes you can install PowerShell on Linux. Just call Copy-Item with the -ToSession parameter passed an SSH connected session, I've never actually tried it though. It requires a recent version of PowerShell and some setting up see PowerShell remoting over SSH. Something like this:
Copy-Item C:\localPath\*.* ~\remotePath\ -ToSession (New-PSSession -HostName UserA#LinuxServer01:22 -KeyFilePath c:\\userAKey_rsa)
If both machines are Windows machines you can use the same -ToSession parameter to copy files over WinRM. But both machines have to be domain joined or there is the possibility of security issues.
There is also a ".NET friendly" way:
you can use the SharpSSH dll to execute ssh commands, and do scp/sftp tranfers.
For example:
[Reflection.Assembly]::LoadFrom((Resolve-Path .\Tamir.SharpSSH.dll))
$ssh = New-Object Tamir.SharpSsh.Sftp("server","user","password")
$ssh.Connect()
$ssh.Put("C:\localfile","distantfile")
$ssh.Close()
There is the SSH.Net library, too, it does approximatively the same things.
i have installed fresshd in one of my windows server.now i am connect to the system through putty. It is working fine.
my issue us when i am running from command line
PuTTY.lnk -ssh -2 -P 22 username#XXX -pw pswd -m command.txt
commands given in the command.txt files are not executed it just open the putty console and it is closing.
when Running from Jenkins also same issue.
I am not sure if you are connecting to Windows from a Linux machine, or to Linux from a Windows machine. Or Windows to Windows?
PuTTY.lnk is not an executable. If you try to run that, it should produce an error 'PuTTY.lnk' is not recognized as an internal or external command. I am assuming you are running the command from a Windows machine, since you are referring to windows shortcut file (.lnk)
You need to use PuTTY.exe + the rest of your command line. Please note that unless it is in your $PATH settings, you would have to provide a full path to the .exe, for example C:\LocationOfPuttyInstall\putty.exe -ssh -2 -P 22 username#XXX -pw pswd -m command.txt. For the sake of preventing any other problem, you should also specify a correct full path to the command.txt file.
If you are not sure where your Putty is installed, on the Windows machine, do the following:
Right click your PuTTY shortcut (the PuTTY.lnk file)
Look under "Target"
That would list your full path to PuTTY.exe executable.
This should resolve your problem.
p.s.
Usually Putty is used to connect from a Windows machine to a Linux machine. From your question, it almost looks like you are trying to connect from a Windows machine to another Windows machine.
You should use PsExec windows tool for such purposes:
http://technet.microsoft.com/en-us/sysinternals/bb897553.aspx
I am using winhttpcertcfg to install a certificate into "Certificates (Local Computer) / Personal / Certificates" (MMC)
winhttpcertcfg -i "C:\test.pfx" -c LOCAL_MACHINE\My -p removedForQuestion
Running this command shows the following output (no errors, but nothing suggesting it has worked either:
Microsoft (R) WinHTTP Certificate Configuration Tool
Copyright (C) Microsoft Corporation 2001.
When I search for the certificate (I checked Current User as well as Local Computer) there is nothing to see in MMC.
It actually works just fine with certutil, so I'm using that instead of winhttpcertcfg for the install and then granting permissions separately.
certutil -f -p removedForQuestion -importpfx "C:\test.pfx"
http://msdn.microsoft.com/en-us/library/windows/desktop/aa384088(v=vs.85).aspx
-i Specifies that the certificate is to be imported from a Personal Information Exchange (PFX) file. This parameter must be followed by
the name of the file. When this parameter is specified, "-a" and "-c"
must also be specified.
There are several complexities to be considered while choosing an alternative for winhttpcertcfg.
See answer
https://serverfault.com/questions/620013/importing-a-certificate-and-granting-permissions-on-windows-server-2012-r2/622556#622556
I am building a Windows 7 installer with NSIS for internal company use.
One step in the install is to backup a Postgres DB using pg_dump.exe, then restore a file packaged in the installed usign pg_restore.exe. These two executables are normal helper tools include with any Postgres installation, so they can be expected to exist on the user's machine.
I want to execute this operation like so:
ExecWait 'C:\path\to\file\pg_dump.exe --host localhost --port 5432 --username "postgres" --no-password --format custom --blobs --verbose --file $OUTDIR/myDB.backup myDB' $0
DetailPrint 'Backup DB process return $0'
But the problem I'm having is that the path of executables differs from machine to machine. So I am trying to run a search operation to find the files. Such as this
${Locate} "C:\" "/L=F /M=pg_dump.exe" "locateBackup"
Or this (using locate plugin)
${locate::Open} "C:\" `/F=1 /D=0 /X=exe /-PN="Oracle" /-PF="$WINDIR\System|$WINDIR\System32|$WINDIR\Help" /N=pg_dump.exe /B=1` $0
${locate::Find} $0 $1 $2 $3 $4 $5 $6
Both of those methods fail on Windows 7. The installer crashes when the search traverses certain directories; I'm not sure why.
Next thing I'd like to try is to look up the executables location in the Windows registry, with the NSIS command ReadRegStr, maybe something like this
ReadRegStr $0 HKLM Software\pg_dump ""
DetailPrint "Its installed at: $0"
But I can't find the right registry key for looking up pg_dump (or pg_restore).
Is there a way to identify the path of installed executables on Windows 7 using native NSIS functions?
Or is there a better way to backup and restore Postgres databases with NSIS installers?
You can find the installation directory (if it was installed through the one-click installer) in
HKLM\PostgreSQL\Installation\postgresql-9.1\Base Directory
apparently this key is version dependent. And there can be more than one entry (if more than one version is installed). So you will need to enumerate the entries and pick whatever version fits you.
Then append \bin to the value obtained from "Base Directory" and pg_dump/pg_restore should be there.