I've been trying to make ssh connection using Cygwin, but it doesn't recognize my id_rsa public key file.
My command lines are as follows:
$ssh XXX#XXX -i /home/XXX/.ssh/id_rsa
Warning: Identity file /home/XXX/.ssh/id_rsa not accessible: No such file or directory.
Permission denied (publickey,XXX).
(Sorry, I used XXX for the private information.)
I copied my .pub file to C:\cygwin\home\XXX.ssh folder. But it still spits out the same error message.
Thank you so much in advance.
Background
Most cygwin executables, map Unix path /home/XXX/.ssh/id_rsa to Windows path C:\cygwin64\home\XXX\.ssh\id_rsa. Except that ssh.exe maps the same Unix path to Windows path C:\home\XXX\.ssh\id_rsa.
That is if you do cat ~/.ssh/id_rsa, it will print out the contents of C:\cygwin64\home\XXX\.ssh\id_rsa, but if you do ssh XXX#XXX -i /home/XXX/.ssh/id_rsa it will try to read the key from C:\home\XXX\.ssh\id_rsa.
I assume this is bug in Cygwin. In any event, this is a workaround that worked for me (on Windows 10 and the latest version of Cygwin as of October 2020).
Solution
Open Administrator command prompt. Go to C:\ and issue the command mklink /D home c:\cygwin64\home
That's it.
But for me tat least, once I solved the above problem, I started getting the problem described in this Superuser question https://superuser.com/questions/1296024/windows-ssh-permissions-for-private-key-are-too-open. I used the solution from the most upvoted answer and ssh finally worked for me.
From your post it looks like SSH is looking for /home/XXX/.ssh/id_rsa and is not finding it. Ensure that the .pub file you copied is named correctly and has the right permissions.
Try putting the option before the hostname...
Related
this is my first ever question. Okay..
Relevant to this problem :
I am using cmder
I am new to the terminal
I am using a windows PC
I'm following a tutorial on how to install mongoDB locally, after running the setup my first problem came when
On the terminal The tutor did
Cd ~
To go to the home directory but when I tried the same command on the cmder I received
The system cannot find the path specified
So I navigated manually using "cd.. " to
c:\Users\<username>
Which I think is the home directory,I created the ".bash_profile" file and saved the following commands in it
alias mongod = "/c/program\ files/MongoDB/server/4.4/bin/mongod.exe"
alias mongo = "/c/program\ files/MongoDB/server/4.4/bin/mongo.exe"
But when I run the mongod or test if it's installed completely it returns
'mongod' is not recognized as an internal or external command, operable program or batch file
Please I don't know my way round the terminal that much, please be detailed with answers
Thanks in advance
alias mongod="/c/Program\ Files/MongoDB/server/4.4/bin/mongod.exe"
alias mongo="/c/Program\ Files/MongoDB/server/4.4/bin/mongo.exe"
Removing spaces and making uppercase the first letters of program files worked for me.
cmder doesn't interpret shell arguments like ~, which means tilde won't work in paths. Also, be aware the way you spelled Cd. It can cause an error in other command line tools (case sensitive ones like Git Bash).
1 - If you're using cmder/cmd.
Use doskey to create an alias/shortcut:
Create C:\bat\macros.txt to store your macros/aliases and paste:
cdhome=cd /d %HOMEDRIVE%%HOMEPATH%
mongo="C:\Program Files\MongoDB\Server\4.4\bin\mongo.exe" $*
mongod="C:\Program Files\MongoDB\Server\4.4\bin\mongod.exe" $*
Rename everything you want but %HOMEDRIVE%%HOMEPATH%. $* at the end means the command accepts arguments, like mongo --version.
Keep in mind that .bash_profile isn't related with cmder/cmd, that's why your mongo commands are there too.
Then Windows + R and type regedit.
Go to HKEY_LOCAL_MACHINE\Software\Microsoft\Command Processor\
Right-click and add a new "String Value". Name it Autorun.
Right-click it and modify the value data to DOSKEY /MACROFILE="C:\bat\macros.txt"
2 - If you're using Git Bash, Hyper terminal, etc.
On .bash_profile, just remove the spaces around the equals sign. Like:
alias mongod="/c/program\ files/MongoDB/server/4.4/bin/mongod.exe"
alias mongo="/c/program\ files/MongoDB/server/4.4/bin/mongo.exe"
or on Windows, you can just go to System properties/Advanced/Environment Variables. Under System variables, find the Variable called Path. Click edit, then New and paste in the path of the mongoDB bin folder:
C:\Program Files\MongoDB\Server\4.4\bin
keep in mind to write version your mongodb correctly in path, now its 4.4
By adding a path to the path variable you can access the .exe files from that path no matter where you are in the directory. It serves the same purpose as the .bash_profile file. Doing it this way allows this to work with windows cmd prompt or cmder as well. Upon launching, the bash emulator gets the environment variables from Windows anyways.
After adding the mongoDB path, open cmd prompt or any bash emulator and type in mongo. It will load up mongo.exe regardless of your current working directory.
Be Specific about the spaces after alias.
alias alias_name ="path.."
I faced alot of issues despite so many answers so this worked for me.
1.First install git and hyper terminal
2.Click the '~' sign to enter the home directory and then make a new file ".bash_profile"
Enter the command "vim .bash_profile"
Now enter 'i' key to enter the insert mode
Copy paste the exact command below:
alias mongod="C:/Program\ Files/MongoDB/Server/5.0/bin/mongod.exe"
alias mongo="C:/Program\ Files/MongoDB/Server/5.0/bin/mongo.exe"
(make sure that you use forward slash '/' for path and "\" backward slash to indicate space between program and files)
enter esc
write the command ':wq!' and click enter
restart hyper terminal and check the installation by running the command 'mongo --version'
Use git bash instead of CMDER
OR
Try to install mongosh from this link:
[1]: https://www.mongodb.com/try/download/shell?jmp=docs
And after setup go to hyper terminal and write mongosh => to connect to MongoDB on port 27017 and then you will see => test>
now you are ready to use the Database and you can write help to see Shell Help.
Check if mongo.exe or mongod.exe files are exist. In my case the bin directory had mongos.exe instead of mongo.exe.
'ls' is not recognized as an internal or external command, operable program or batch file.
I get this error when I try to glance at the files of my folder.
cmd opened regularly(not as an admin).
I've recently downloaded anaconda for python.During the installation process, there was a time when I allowed to add a PATH which was not recommended.
'ls' used to work well be
Here are the paths
I'm fairly certain that the ls command is for Linux, not Windows (I'm assuming you're using Windows as you referred to cmd, which is the command line for the Windows OS).
You should use dir instead, which is the Windows equivalent of ls.
Edit (since this post seems to be getting so many views :) ):
You can't use ls on cmd as it's not shipped with Windows, but you can use it on other terminal programs (such as GitBash). Note, ls might work on some FTP servers if the servers are linux based and the FTP is being used from cmd.
dir on Windows is similar to ls. To find out the various options available, just do dir/?.
If you really want to use ls, you could install 3rd party tools to allow you to run unix commands on Windows. Such a program is Microsoft Windows Subsystem for Linux (link to docs).
We can use ls and many other Linux commands in Windows cmd. Just follow these steps.
Steps:
1) Install Git in your computer - https://git-scm.com/downloads.
2) After installing Git, go to the folder in which Git is installed.
Mostly it will be in C drive and then Program Files Folder.
3) In Program Files folder, you will find the folder named Git, find the bin folder
which is inside usr folder in the Git folder.
In my case, the location for bin folder was - C:\Program Files\Git\usr\bin
4) Add this location (C:\Program Files\Git\usr\bin) in path variable, in system
environment variables.
5) You are done. Restart cmd and try to run ls and other Linux commands.
you can use dir instead of ls in cmd
If you want to use Unix shell commands on Windows, you can use Windows Powershell, which includes both Windows and Unix commands as aliases. You can find more info on it in the documentation.
PowerShell supports aliases to refer to commands by alternate names.
Aliasing allows users with experience in other shells to use common
command names that they already know for similar operations in
PowerShell.
The PowerShell equivalents may not produce identical results. However,
the results are close enough that users can do work without knowing
the PowerShell command name.
when you use windows as operating system you should write dir
and you will find all folders including empty folders and their data bytes storage
and you can use git ls-files to show all folders but not including hidden folders
The reason you cannot run the ls command is because it does not exist on windows. The windows equivalent is the dir command, however it does not work the same way. The solution, Winls. It is
The ls command, written for windows.
According the the Winls github.
Had this error because i was using command prompt to access my files.
how did i solve it...
i opened my folder with vscode, and used bash from the terminal...the "ls" command worked as it should from bash.
First of all, I don't know Batch programming at all. I came across a FIND command in a tutorial I was reading about OpenCV
http://coding-robin.de/2013/07/22/train-your-own-opencv-haar-classifier.html
find ./positive_images -iname "*.jpg" > positives.txt
It basically is supposed to copy all the relative paths of all the jpeg files inside positive_images directory to positives.txt file. I ran this in CMD(as Administrator) and got the following:
What is the meaning of Access Denied? I don't want to learn Batch Programming for this as I am already busy in my project. Please give me a simple-to-understand solution.
The referred tutorial uses the bash find command.But you're executing the Windows find command.Download from somewhere the windows port for the unix command put it in your directory and call it like
.\find.exe .\positive_images -iname "*.jpg" > positives.txt
mind also the windows path separator slashes.
you can use this port for example -> http://unxutils.sourceforge.net/
(probably there's a newer port but this should do the work)
I have been using the cake command on my linux server for 2 years. but now im trying to move to a new server and some how the cake command gives back the error: No such file or directory
even if i give the entire path to the cake command file chmod 777 it stil wont work.
I found the solution: All I had to do is use the program dos2unix the cake file for CakePHP 2.4.2 has wrong endings when you download it with Ubuntu 13.10
I used the following command:
sudo dos2unix /path/to/cake/lib/Cake/Console/cake
I also have this problem on some servers and never figured out why this happened. I suspect the so called "shebang" might not be set correctly for every Linux distribution (e.g. if the cake script stars with #!/usr/bin/env bash, but you don't use bash on your server or your distribution doesn't have the env binary in that path, it might fail on that. This is just a theory though, as I said I never really figured it out, nor did I invest much time in investigating.
Although, what I always use as a fallback is simply calling the cake.php script (from the app folder) instead, like:
php Console/cake.php -app `pwd` bake
That never lets me down. The -app pwd bit is to tell the shell that your current directory is your app directory, so the shell can find all your files.
The REAL solution to this is to change the End-of-Line (EOL) characters to Unix format, instead of MsDos. So I guess this error will only occur if you worked in Windows.
Anyway, teh mighty
SOLUTION:
(1) Open app/Console/cake file using any text editor that allows changing of EOL characters e.g. NotePad++.
(2) In NotePad++ click:
Edit -> EOL Conversion -> Convert to Unix format
(3) Save the file and upload it to the server. Now if you navigate to the CakePHP app directory using command like:
cd /usr/share/nginx/html/cakeproject/app
...you should be able to run Console/cake without any problems and see standard output (basically help commands).
Hope this helped you!
I encountered the same problem as well, but the top answer reminded me of a similar problem I faced before: https://stackoverflow.com/a/5514351/1097483
Basically, instead of using dos2unix or installing it, you can open the file in vim, do
:set fileformat=unix
And save it.
In some versions it's possible to install cake using sudo apt-get install cakephp-scripts.
After instalation, you coud access bake anywere simple by typing bake
I'm trying to install postgres on a sun solaris sparc instance in my home directory.
Everything is fine except when I try to start postgres server, I get the following error
FATAL: "/home/reic/var/lib/pgsql/data" is not a valid data directory
DETAIL: File "/home/reic/var/lib/pgsql/data/PG_VERSION" is missing.
I used the command pg_ctl -l logfile start to start the server.
I have followed all the necessary steps for installation on sun solaris.
Any idea as to why is this happening ?
Solution:
All the necessary files are there in the PGDATA directory and I ran it as the same user which is trying to start the server. The problem is with the placement of env variables in the .bashrc instead of .bash_profile file. Apparently the customisations are not propagated to sub shells when the env variables are put in .bashrc.
My bad for not realising this! Thank you all....