While generating the private key using this command
genrsa -out my-prvkey.pem 1024
It throws the error like below
Loadind 'screen' into random state -done Generating RSA private
key,1024 bit long modulus
.........................................+++++++
...........................+++++++++ unable to write 'random state' e
is 65537 (0*10001)
This makes any problem while creating a public certificate. I'm running this command in windows. Can anyone help me for the fix?
The quickest solution is: set environment variable RANDFILE to path where the 'random state' file can be written (of course check the file access permissions), eg. in your command prompt:
set RANDFILE=C:\MyDir\.rnd
openssl genrsa -out my-prvkey.pem 1024
More explanations:
OpenSSL on Windows tries to save the 'random state' file in the following order:
Path taken from RANDFILE environment variable
If HOME environment variable is set then : ${HOME}\.rnd
C:\.rnd
I'm pretty sure that in your case it ends up trying to save it in C:\.rnd (and it fails because lack of sufficient access rights). Unfortunately OpenSSL does not print the path that is actually tries to use in any error messages.
It may also be that you need to run the console as an administrator. On windows 7, hold ctrl+shift when you launch the console window.
just enter this line in the command line :
set RANDFILE=.rnd
Or this in windows powershell
$env:RANDFILE=".rnd"
I did not find where the .rnd file is so I ran the cmd as administrator and it worked like a charm.
Download openssl for windows from https://code.google.com/archive/p/openssl-for-windows/downloads
Set Environment variable to the path variable as path="C:\your_folder\openssl-0.9.8k_X64\bin"
Run below commands on the same path of bin
Related
When I try to connect my Mac, then I get this error.
I read a log where to found it:
System.NotSupportedException: Key 'OPENSSH' is not supported.
at Renci.SshNet.PrivateKeyFile.Open(Stream privateKey, String passPhrase)
at Renci.SshNet.PrivateKeyFile..ctor(String fileName, String passPhrase)
at Xamarin.Messaging.Ssh.MessagingAuthenticationMethod.InitializePrivateKeyAuthentication(String username, ISshInformationProvider sshInformationProvider) in E:\A\_work\157\s\External\messaging\src\Xamarin.Messaging.Ssh\MessagingAuthenticationMethod.cs:line 76
at Xamarin.Messaging.Ssh.MessagingService.GetMessagingConnection(Func`1 passwordProvider, ISshInformationProvider sshInformationProvider) in E:\A\_work\157\s\External\messaging\src\Xamarin.Messaging.Ssh\MessagingService.cs:line 418
at Xamarin.Messaging.Ssh.MessagingService.<ConnectAsync>d__64.MoveNext() in E:\A\_work\157\s\External\messaging\src\Xamarin.Messaging.Ssh\MessagingService.cs:line 167
I found library and code that it's using:
https://github.com/sshnet/SSH.NET/blob/bd01d971790a7c1fa73bad35b79ada90bf69e62d/src/Renci.SshNet/PrivateKeyFile.cs#L190
and there is nothing about OpenSSH like a keyName.
I check my private keys in folder %LOCALAPPDATA%\Xamarin\MonoTouch:
-----BEGIN OPENSSH PRIVATE KEY-----
...
-----END OPENSSH PRIVATE KEY-----
I began to receive this error when I reinstalled Windows 10 and Visual Studio 2017 instead of Windows 7
Please help me solve it
I execute below command in command-prompt, and retry connecting Mac.
ssh-keygen -t rsa -b 8192 -N "" -f "%LOCALAPPDATA%\Xamarin\MonoTouch\id_rsa"
-t specifies encryption type 'RSA'
-b use 8192-bit key
-N explicitly specifies empty keyphrase
I can confirm that user10613465's answer worked in my case.
ssh-keygen -t rsa -N "" -f "%LOCALAPPDATA%\Xamarin\MonoTouch\id_rsa"
In my case I had the correct versions of Windows, Visual Studio and Xamarin.
The system passed until tests number 8 and 9 described here:
link from official Xamarin on MS Docs
I know it's manner to comment on his asnwer, but I don't have the privillege yet (using work email's StackOverflow account)
It's indeed caused by a bug in Xamarin. The solution suggested by user10613465
does not work with recent versions of Xamarin (at least not for me), however I've found a workaround.
Background
Feel free to skip this section* Xamarin generates a pair of SSH keys
stored in in %LOCALAPPDATA%\AppData\Local\Xamarin\MonoTouch. SSH key files comes
in multiple flavors. One is RSA, another is OPENSSH. The flavor can be
found by inspecting the first line in the key file. The problem here
is Xamarin generates OPENSSH keys; but can't read them.
In recent versions of Xamarin the private key is encrypted and the
passphrase itself is encrypted and stored in a file named
passphrase.key. If you attempt to erase the files and generate a new
keyset of the correct flavor as suggested, Xamarin will reject the
keys a generate a new set it doesn't understand.
Stategy
Feel free to skip this one too. My research suggests you can't
convert an OPENSSH key to a RSA key. As far as I can see, Xamarin does
not use any external program to generate the key set, so replacing/redirecting
is not a viable solution.
The solution I found is to generate a new keyset of the supported
flavor, with the same passphrase and leaving passphrase.key in place. Getting the passphrase is the tricky part. I've used VS to debug another instance of VS to obtain it.
Procedure
I assume you already have attempted ot pair and have a defective key
pair (id_rsa, id_rsa.pub and passphrase.key)
Fire up Visual Studio (VS), open some project. We'll call this
instance A of VS.
Select Tools -> IOS -> Pair to mac.
Enter IP address or name of your Mac, but DO NOT enter name and
password yet.
Start another instance of VS. We call this instance B.
In instance B, select Debug -> Options
In Debuging -> Options, deselect "Enable Just my code", Click OK.
Select Debug, Attach to Process.
Select the Instance A of VS. The process is called devenv.exe.
In instance B, Select Debug -> Windows -> Breakpoints
In the breakpoints window, click on New -> Function breakpoint. Select
Renci.SshNet.PrivateKeyFile.Open.
Now, in instance A, enter name and password and click OK. The
breakpoint is now hit by instance A so it freeze.
In instance B you should see some assembler code. The code itself is
not important; but we should be able to see the arguments to the
method. Open the local variable window by clicking through Debug ->
Windows -> Locals
One variable is the passphrase. It looks like a uuid. Copy it to the
clipboard and store it somewhere convenient.
Resume execution, close both VS instances.
Enter C:\Users\mk\AppData\Local\Xamarin\MonoTouch
Verify you can connect to your mac using the key and the passphrase we
just recovered:
ssh -i id_rsa mymac
Move the old key out of the way:
mkdir old
move id_rsa old
move id_rsa.pub old
Generate a new set of keys, use the same passphrase.
ssh-keygen -t rsa -N "" -f "%LOCALAPPDATA%\Xamarin\MonoTouch\id_rsa"
Verify the header in id_rsa looks like this
----BEGIN RSA PRIVATE KEY-----
and not like this
-----BEGIN OPENSSH PRIVATE KEY-----
If it doesn't, you need to use another ssh-keygen. Perhaps putty can
help you there.
Log in to the mac computer. Edit .ssh/authorized_keys and remove the
old key. (The one you find in
"%LOCALAPPDATA%\Xamarin\MonoTouch\old\id_rsa.pub"
Add the new public from "%LOCALAPPDATA%\Xamarin\MonoTouch\id_rsa.pub"
This solved the problem for me
I am writing a Java application and part of it involves zipping/unzipping folders with a password encrypted. The code I use in Java to run terminal commands is:
p = Runtime.getRuntime().exec(command);
p.waitFor();
When I choose to zip a particular folder, the terminal call is:
command = zip -P password -r encrypted.zip folderIWantToZip
When I choose to unzip a particular folder, the terminal call is:
command = unzip -P password encrypted.zip
I detect when a user enters a wrong password (when trying to unzip) if the p.waitFor() value is 1 and not 0.
I am testing my application on a Mac and it seems to be working fine. I am assuming that these terminal calls will work exactly the same on Linux machines as well and I should be getting the same result.
I was wondering what would be the equivalent terminal/command prompt commands on a Windows machine to zip and unzip folders with password encryption. I have heard that this is not possible on command prompt without downloading a third party software like 7zip. In this case, what would be the equivalent terminal commands using 7zip/some other equivalent third party software such that this application would work on Windows?
I've been trying to install the 64bit version of PostgreSQL 9.2 for Windows on my machine (Windows 7 64bit) and get this error:
The environment variable COMPSPEC does not seem to point to the cmd.exe or there is a trailing semi colon present.
I've installed it as Administrator.
I disabled the antivirus (Microsoft Security Essentials) and the firewall.
Running:
"%COMSPEC%" /C "echo test ok"
returned test ok
I've checked my System Environment Variables for trailing semi colon and I couldn't find any.
I then installed the 32bit version and managed to get to the end of the install with a different error message stating: Problem running post-install step. Installation may not complete correctly Error reading the C:\Program Files (x86)\PostgreSQL\9.2\data\postgresql.conf but there is no postgresql.conf file in that directory. It did install the application and when I try to connect the server with the red X on it it says fail at the bottom and it won't connect after I type in my password.
How can I connect to this server connection?
ComSpec is a generic error message for any installation failure.
Identifying the problem
Navigate to below path
c:\Users\XXXXXX\AppData\Local\Temp
Open 'bitrock_installer_XXXX.log'
Check, if you are getting below error:
Script stderr:
'"C:\Users\XXXXX\AppData\Local\Temp\POSTGR~1\TEMP_C~1.BAT"' is not recognized as an internal or external command, operable program or batch file.
Error running
C:\Users\XXXXX\AppData\Local\Temp/postgresql_installer_47b21c4ea1/temp_check_comspec.bat :
'"C:\Users\XXXXX\AppData\Local\Temp\POSTGR~1\TEMP_C~1.BAT"' is not recognized as an internal or external command,
operable program or batch file.
This is a problem with '8.3 file names and directories' (e.g. '\Postgres Install' -> '\POSTGR~1')
Microsoft article on disabling 8.3 file names and directories: https://support.microsoft.com/en-gb/kb/121007
Solution:
Open command prompt in admin mode
Execute following command to change the format based on your drive or all drives
Sample commands:
fsutil 8dot3name set 1" - disable 8dot3 name creation on all volumes
fsutil 8dot3name set C: 1" - disable 8dot3 name creation on c:
Execute the installation as a user having admin privileges
After install, consider resetting the 8dot3name setting to default (2) to avoid unintended consequences
Hope it solves the problem!
Very easy fix:
Just open Advanced System Settings in Control Panel and create a new System Variable( in the System Variable instead of User Variable section).
In the variable name, enter ComSpec and then in the variable value , enter C:\Windows\system32\cmd.exe.
Alternative fix:
If you have already the ComSpec variable in the System Variable section, remove the ;at the end of it this should fix it.
It's not COMPSPEC it's just COMSPEC. Please show the output of:
echo %COMSPEC%
Note that COMSPEC could be set to something different in the Administrator account you're running the installer as. I'm not sure how to find that out, but it might appear in the PostgreSQL installer log, so please upload that and link to it in your post. See Reporting an installation error for info on where to get the installer log.
See the PostgreSQL for Windows FAQ entry Check the COMSPEC environment variable.
Here's a report I made suggesting that the installer should test for this explicitly and here's my blog post on the topic.
I got the same problem, and i found in the log:
Script stderr:
'C:\Users\S300' is not recognized as an internal or external command,
operable program or batch file.
Error running C:\Users\S300 (i5)\AppData\Local\Temp/postgresql_installer_56caeadbd6/temp_check_comspec.bat : 'C:\Users\S300' is not recognized as an internal or external command,
operable program or batch file.
I change in User Variables TEMP to D:\TEMP and TMP to D:\TEMP.
And Solved My Problem.
In my case , the Installer was in %USERPROFILE%\DownloadsP{ Windows download folder}, I moved the installer to desktop and ran again. weird it worked lol.
I had a similar problem. After installation, the data folder contained no postgres.conf file. It only contained a single folder named "pg_log".
I described the solution that I used here: Postgres Installation Error reading file postgresql.conf
Basically, it would be helpful to check if the user has full permissions for the postgres folder, and run "init_db" and "pg_ctl start" commands again. If the path contains a space character, try using a relative path for the pg_ctl data folder argument.
I'm running Windows Server 2003 R2, and I have been unable to resolve this problem with the installer, so I resorted to using the binary PostgreSQL package. Hopefully this will be an alternative for others who do not want to perform an OS reinstall.
First, some background (hopefully useful to the developers)
It started out with the postgres service failing to start (the server had been running reliably for over a year). I assumed it was a corrupted PostgreSQL installation, so I uninstalled and attempted to reinstall. I encountered the following error:
There has been an error.
The environment variable COMSPEC does not seem to point to the cmd.exe or there is a trailing semicolon present.
Please fix this variable and restart installation.
However, the COMSPEC variable is set properly, verified with:
echo %COMSPEC%
C:\WINDOWS\system32\cmd.exe
and:
"%COMSPEC%" /C "echo test ok"
test ok
Since this is Windows Server 2003, there is no UCA wrapper around the Administrator account, so that is not causing the problem.
Manual Installation
NET USER postgres /ADD
C:\pgsql\bin\initdb.exe -U postgres -A password -E utf8 -W -D C:\pgsql\data
runas /user:postgres "C:\pgsql\bin\pg_ctl -D C:/pgsql/data -l C:/pgsql/logfile.txt start"
just do it run as administrator and change the environment system variable
like create a new variable 'ComSpec' and value type 'C:\Windows\system32\cmd.exe'.
If the installer exe is on a network share that mapped drive might actually not be accessible to the installer as it runs as administrator. This can often happen in some virtual machine arrangements such as running windows in a parallels VM. Copy the installer to a local drive first and you won't have a problem.
What worked for me after trying to enter the commandline given her in cmd.exe
I found it was named cmd1.exe in system32.. so i copied the file and renamed it as cmd.exe and installation finished
Open Environment Variables, you can do this on Windows 7 by typing environment variables in the Search program and files bar when pressing the start button at the bottom left of the desktop. And create a new System Variable(in the 'System Variable' instead of 'User Variable' section).
In the variable name, enter ComSpec and then in the variable value , enter C:\Windows\system32\cmd.exe.
That's all. Hope it works!
Alternative fix:
If you already got the ComSpec variable in the System Variable section, remove the ; at the end of it this should fix it.
First find the path to cmd.exe(mostly it is C:\Windows\System32\cmd.exe).
Go to the enviornment variable and add this path to system variable path.And also create new variable in user variable called ComSpec and add this path as value. And you are ready to go.
I am trying to use Emacs 24.2 with Tramp on windows 7 to remotely edit files on a linux server. I installed the Putty suit program and OpenSSH. I also placed the plink.exe in the putty suit into the bin folder under the emacs 24 folder, and added the folder emacs24/bin into the PATH environment variable.
However, when I try to access the remote file from emacs with the command in the minibuffer: /username#host:filename, I get the following error message from emacs: plink is not recognized as an internal or external command. It seems that emacs cannot find the plink program. But, when I try to run plink in windows cmd, it can find the plink program. Also, I can ssh to the remote server in windows cmd.
Can anyone tell me what's my problem? Do I need to install cygwin to make it work? Thanks a lot.
To get tramp with plink to work, I had to add my PuTTY path to my system search path.
On Windows 10:
control panel >> System & Security >> System >> advanced system settings >> enviroment variables
To PATH I appended the PuTTY path: C:\Program Files (x86)\PuTTY
I'm guessing the key is that from PowerShell or the command prompt, you need to be able to run plink without specifying the path.
I was able to resolve this and I did not have to install cygwin.
Try adding the path where putty was installed to your exec-path variable in emacs. Execute the following elisp code in emacs or put it in your .emacs file. Make sure the slashes are forward, not backslashes, as Emacs and Windows use different conventions.
(add-to-list 'exec-path "C:/Program Files (x86)/PuTTy")
check what exec-path is set to by typing C-h v exec-path
I recently came across a problem generating self-signed certificates in an automated fashion. Anytime I run makecert.exe I get a pop-up window for a password for the certificate. However, these certificates will never be distributed, so I don't need a password or anything.
How can I get makecert.exe to work without requiring a GUI?
If it helps, my command line takes this kind of form:
makecert.exe mycert.cer -r -n "CN=random-hex-number" -$ individual
-sv private.pkv -pe -cy end
I didn't solve the root problem, but found a way to work around it. It only prompts for a password when you don't provide a private key. By generating a private key beforehand and passing it as the PVK, it won't prompt for a password now.
Put the certificate and the private keys in a folder.
then use the pvk2pfx tool to combine them into one file.
Then when your ready to install use
#pushd "%~dp0"
#start "" /b (command) "%~dp0"
The pushd keeps it the files directory, and start "" /b runs the program without bring up the interface.