Don't understand how to use SSH keys with "ssh" and "scp" commands on Lubuntu
I recently acquired an old netbook (Asus Eee PC 901) and installed Lubuntu 13.10 on it. I have a server at home, and SSH into it all the time from my Windows laptop. I made a new SSH key on my Windows laptop with PuTTYgen, put it on the server, and copied the private key to the netbook. I then ran this:
Code:
ssh -i key.ppk -p (port #) anthony@10.0.0.26 Code:
Enter passphrase for key 'key.ppk': Code:
Permission denied (publickey). At this point, I'm completely lost. I made sure that I typed the passphrase correctly, the key works through PuTTY, but the "ssh" and "scp" commands refuse to use it. |
read the links in my sig. they will help. ask if you have further questions.
|
To copy a file or many files to ssh server
scp -P <port num> file(s) user@xxx.xxx.xxx.xxx:<destination> scp uses a capital 'P', while ssh uses a lower case 'p'. If your ssh port is 22, you don't need the p's flag. The following example will copy the public key to the ssh server. Code:
scp -P <port num> ~/.ssh/id_rsa.pub user@192.168.100.15:~/.ssh/authorized_keys Code:
ssh -p <port num> user@xxx.xxx.xxx.xxx |
Quote:
|
Quote:
The code I gave is an example of setting up the public key for the first time to a new authorized_keys file. |
Hi,
ssh-copy-id is a very useful little script (in the openssh-client package on Debian and derivatives) which will append the key to the authorized_keys file. Regarding debugging the original problem, try running ssh with versbose output, and to get even more information have a look at the sshd log (eg /var/log/auth.log). Evo2. |
Thanks for the responses!
Unfortunately, I wasn't thinking when I posted this thread, and I'll be out of town and won't be able to try any of this until next week, maybe later. I'll get back with you then, but until then I won't have access to the machine that I'm having the problem on. Sorry for the lack of foresight. Thanks again, and I apologize that I can't test anything until next week. |
I'm back.
Here is the verbose output: Code:
anthony@Anthony-Eee:~$ ssh -v -p xxxx anthony@10.0.0.26 -i key.ppk Code:
anthony@Anthony-Eee:/var/log$ cat auth.log It appears that it is not recognizing the SSH key properly. I made it with PuTTYgen on another computer, and transferred it via flash drive. Does the ssh command have problems recognizing PuTTY keys? |
I found the the turorial on the github to be a very nice one. how to ssh-key
As a matter of fact just learning how to set up a git repo ,just for fun. Will be the best to learn this type of stuff . |
Quote:
Create a new key with ssh-keygen and upload it to your server using ssh-copy-id. That should do the trick EDIT: You will want to temporarily allow password logins on the server for the ssh-copy-id script to be able to upload the new key. |
Quote:
Give each machine its own key and put them both in the authorized keys file on the server. Trying to share a single key between multiple client machines is both unsafe and a PITA. |
Quote:
The only reason I had to transfer the file via flash drive is because PuTTYgen is a ".exe" and was the only way I knew how to make keys. But thanks to joe_2000, I now know the right thing to tell Google, and can do it the right way :). I'll just save the public key to that same flashdrive, stick it in my laptop, and put it in through there. I don't have a chance to do it now, though, but I should be able to tomorrow. Depends if the snow tonight is enough to cancel school. :study: |
Wow...I thought it would be tow days not weeks. But that's what happens during research paper season...
I generated a new key with the "ssh-keygen" command, and copied it to my server, and it works! Thanks for helping me with this! I'm marking this thread as solved. |
All times are GMT -5. The time now is 06:33 AM. |