I had to wipe out my Windows OS. I went to check if I had ab ssh still and there was none so I created one.
Went through the proper steps and even got the agent ID.
Now when I try and find the id/rsa/pub using bash it tells me no file or directory.
But I can find that ssh file using my file explorer.
Trying to get ssh keys to reload up to my GitHub and Heroku.
After searching stackoverflow I did find an article saying to run the command env|grep HOME and make sure HOMEDRIVE=C: was set to HOMEDRIVE=C:Users/Samson/ but mine is not.
If that is the correct fix how do i set HOMEDRIVE=C: = to Users/Samson/
I am on a Windows Machine
If that isn't the correct fix, I'm open to suggestions. I am extrememly green to this.
Problem
There are two problems in the attempt to display the ssh public key, shown in the screenshot:
No command is used, the file path is entered directly. The command cat may be used for this purpose.
The file path is incorrect: id_rsa/pub instead of id_rsa.pub.
Solution
In order to view the public key file content, try the following command in bash:
cat ~/.ssh/id_rsa.pub
Otherwise, you may simply open the file from windows explorer, using a text editor (e.g. notepad).
You have to generate key first
Use this command to generate key
ssh-keygen -t rsa -b 4096 -C "youremail#example.com"
Enter the above email which you have in you github.
And now press enter and then you key will generate, and you will be able to acquire you ssh key
This command --
ssh-keygen -t rsa -b 4096 -C "youremail#example.com"
I am on a Windows Machine
Its okay to be on a Windows machine, but you should run these commands from a Git Bash window and not a windows command prompt or an anaconda command prompt. That maybe your real problem.
Related
I am developing a script that will automatically keep a folder on two workstations synchronized using rsync. So far, I have gotten everything to work but I have one small thing I haven't figured out. Once, the rsync command is executed, it prompts for the password of the other workstation. However, I haven't been able to find a way to automatically enter that password once prompted in the terminal. I tried using the expect command, but that didn't work as the command didn't execute until after I enter the password.
Is there a solution to this?
Here is my script. I have two instances of the same VM, hence the same usernames
#!/bin/bash
LOCAL="/home/rams/Documents/"
RSYNC_OPTIONS="-avh --progress /home/rams/Documents/ rams#192.168.1.39:/home/rams/Downloads/"
PASSWORD="rams2020"
while true
do
inotifywait -e modify $LOCAL
rsync $RSYNC_OPTIONS
done
Solution shown here:
https://stackoverflow.com/a/3299970/8860865
TL;DR - Use an SSH keygen to generate a keyfile that will authenticate upon using the rsync command and the password is prompted. https://www.thegeekstuff.com/2008/11/3-steps-to-perform-ssh-login-without-password-using-ssh-keygen-ssh-copy-id/
how to run commands like ftp or sftp or scp in background? Also how to setup password less connection for running these command?
Look for manual pages for scp or rsync, which both can do this job well, if not being forced you don't want to use sftp or even the non encrypted ftp file transfer!
something like the following, for example:
rsync [some other parameters] -e ssh SOURCE TARGET
Assuming these commands are coming from a bash script , you would need to make sure that the two (or more ) systems have ssh certificates generated that allow you to access said systems without providing a "password" per se.
Briefly, you could do it by running this command on one system:
ssh-keygen
following through, this will generate a key. Then run:
ssh-copy-id user#some-remote-system
to copy it to the remote system, which will allow passwordless access, enabling scripts to go about their business without stalling for password prompts.
I have a public-private ssh key pair (generated by ssh-keygen without a passphrase) and I use it with my bitbucket account, in particular with a mercurial repository.
Usually I add manually the private key in my home working pc, using ssh-add ~/.ssh/id_rsa. I'm searching a way to do this automatically at every boot. There are many tutorials but I still have some problems.
I have tried with:
Add the line ssh = ssh -i ~/.ssh/id_rsa -C in my ~/.hgrc mercurial settings file. This one doesn't work.
Create ~/.ssh/config ssh configuration file with the following content:
Host bitbucket-ssh
Hostname ssh://hg#bitbucket.org/...
IdentityFile ~/.ssh/id_rsa
The second one does not work too.
What I'm wrong with? Should I use a simple bash script running ssh-add at every boot?
Thanks in advance.
I know this question is old, but I couldn't find the (imho) correct answer in any of the related questions.
Don't add anything to any of your shell startup scripts, this is unnecessary hackery.
Instead, add
AddKeysToAgent yes
to your .ssh/config
Like this, ssh-add is run automatically the first time you ssh into another box. You only have to re-enter your key when it expires from ssh-agent or after you reboot.
If ssh-add ~/.ssh/id_rsa solves your problem when you call it from the commandline, just add it to your .bash_profile (or equivalent, if you don't use bash) and be done with it. It will get run whenever you log on.
Hi I have been given a task of copying files from a given server to local machine. Even I can do it manually using the command line but I need to write a script to automate it. I dont have any clue how to do it using shell, how to give the password which we would have done manually. I went through other posts but did not get the precise answer.
Are there better ways than using SCP command?
Thanks in advance
The preferred + more secure way to do this is to set up ssh key pairs
That being said, if there's a specific need to supply passwords as part of your shell script, you can use pscp, which is part of putty-tools:
If you are on ubuntu, you can install it by:
sudo apt-get install putty-tools
(Or use equivalent package managers depending on your system)
Here's an example script of how to use pscp:
#!/bin/bash
password=hello_world
login=root
IP=127.0.0.1
src_dir=/var/log
src_file_name=abc.txt
dest_folder=/home/username/temp/
pscp -scp -pw $password $login#$IP:$src_dir/$src_file_name $dest_folder
This copies /var/log/abc.txt from the specified remote server to your local /home/username/temp/
Ok guys, maybe this one has been asked before, but I searched and ran threw nothing, so i'm taking a chance here.
I'm using the latest vim (gvim 7.3), on Windows 7 64bits.
I've got some remote files that I want to edit directly with vim, using netrw.
Right now, I've got a fully working transparent ssh connexion to my remote hosts, thanks to Putty, Pageant and public/private keys.
I've successfully setup a read/write access to distant files with those fixes:
#### .vimrc ####
let g:netrw_cygwin= 0
let g:netrw_scp_cmd = 'c:\"Program Files (x86)"\PuTTY\pscp.exe -q -batch'
let g:netrw_sftp_cmd= '"c:\"Program Files (x86)"\PuTTY\psftp.exe'
Then I can access a file with :
:e scp:\\user#host:port\\home\me\some-file.txt
And, each time I access remote file, Vim run a windows prompt (cmd.exe) :
C:\Windows\system32\cmd.exe /c c:\"Program Files (x86)"\PuTTY\pscp.exe -q -batch
-P 22 "C:\Users\me\AppData\Local\Temp\VIF215E.tmp" "user#host:/home/me/some-file.txt"
Hit any key to close this window...
My problem is that hitting a key outside Vim each time I want to open/write a file isn't efficient at all.
So my question(s) is(are) :
Am I doing it the right way ?
Is there another way of transparently
accessing a remote file with ssh on
Windows ?
If no, is there a way to
get rid of "Hit any key to close this
window..." when Vim launches putty's pscp.exe ?
Thanks a lot and happy vimming.
EDIT: Note to the myself in the past: Dude, just go with linux and vanilla gvim/ssh. You'll thank me later (and take a look at spf13-vim)
These are what I got working today (gVim 7.3 in Win 7) (took me many hours to finally get something working):
set nocompatible
let g:netrw_cygwin = 0
let g:netrw_list_cmd = "plink.exe -P ##### -pw MyPass user#host.com ls -Fa "
let g:netrw_ssh_cmd = "plink -T -ssh"
let g:netrw_scp_cmd = "pscp -P ##### -pw MyPass -scp"
let g:netrw_sftp_cmd = "pscp -pw MyPass -sftp"
or
let g:netrw_sftp_cmd = "psftp -P ##### -pw MyPass user#host.com"
With the first command make sure there's a [space] after -Fa or you'll get errors.
Then you can connect in Vim via
:e scp://user#host:port#/(path to file)
:e sftp://user#host:port#/(path to file)
I hope this helps some Vimmers struggling to figure this out and get it working.
Cheers!
Just put this line in your vimrc:
let g:netrw_silent = 1
This will run scp asynchronously (like using !start)
This seems a bit too elaborate.
I use SSHFS on Linux to accomplish this. It allows you to locally mount a remote path over SSH.
Something similar is available for Windows now as well: http://dokan-dev.net/en/. It should remove the need for all the modifications on the Vim side.
Instead of
let g:netrw_scp_cmd = 'c:\"Program Files (x86)"\PuTTY\pscp.exe -q -batch'
I had to use
let g:netrw_scp_cmd = 'c:\"Program Files (x86)"\PuTTY\pscp.exe -q'
In windows 7, putty version 0.6, -batch option was not working!
WINSCP is awesome. I think it copies a temp file locally then FTPs it but it is "transparent" and is very user friendly.
I find it's a lot easier to just run cygwin. Install openssh and gvim in cygwin, then run:
$ gvim scp://user#host//path/to/file
Note the double slashes between the host and the path. Without the extra slash, it'll read the path as relative to the user's home directory.