Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I'm following a tutorial and it's going along well. I used ssh to connect fine. Then I created a private and public key. Which leads me to my first question it says that the keys have been saved to

Your identification has been saved in /home/localuser/.ssh/id_dsa.

Your public key has been saved in /home/localuser/.ssh/id_dsa.pub.

But when I look in that folder I don't see the .ssh folder. Is this done for security reasons and it's supposed to be hidden?

Next the tutorial instructs to manually copy the public key to the remote machine using this command:

scp ~/.ssh/id_dsa.pub username@mywebpage.com:.ssh/authorized_keys

When I run that command I get this response.

ssh: connect to host mywebpage.com port 22: Connection refused lost connection

So, like I do when I first connected by ssh, I add -p 2222 at the end of scp command. I then get this response:

2222: No such file or directory

I've also tried uppercase -P 2222

What am I doing wrong?

PS I'm using Linux Mint 15 and Cinnamon

EDIT

OK. Adding -p 2222 right after ssh worked. However I've ran into another issue.

It then transferred the file. However I had to create the directory myself before it would transfer. Now it's supposed to ask my for my passphrase instead of my password. It didn't do this so then the tutorial said to run these commands. chmod 700 ~/.ssh & chmod 600 ~/.ssh/authorized_keys. But when I login it still asks for my password and not my passphrase.

Why is it not working?

EDIT: I ran ssh with -v these are the mentions of public key:

debug1: Authentications that can continue: publickey,password,keyboard-interactive
debug1: Next authentication method: publickey
debug1: Offering DSA public key: /home/localusername/.ssh/id_dsa
debug1: Authentications that can continue: publickey,password,keyboard-interactive
debug1: Trying private key: /home/localusername/.ssh/id_rsa
debug1: Trying private key: /home/localusername/.ssh/id_ecdsa
debug1: Next authentication method: keyboard-interactive

I'll note this is prior to logging in.

share|improve this question
    
Your intial question is solved; please accept the answer that was most helpful and then search for a similar question for your edit. If one doesn't already exist, open one. Please don't keep editing new (even if seemingly related) questions into this one. –  jasonwryan Nov 8 '13 at 19:09
    
Try running ssh with -v or even -vv to get more verbose output. There should be some text in the output about an attempt to use your public key, and then there will be an explanation as to why it didn't work. You could then add that into your post. –  dg99 Nov 8 '13 at 19:12
    
@dg99 OK. I've done that. You can take a look. –  Chakotay Nov 8 '13 at 19:24
    
You're looking for any error messages that explain why the id_rsa attempt failed. If there's no text there, you should try ssh -vv and then ssh -vvv if necessary. Also, you should definitely take the advice @jasonwryan gave to heart and start an entirely new question lest this one get closed for breaking the rules. –  dg99 Nov 8 '13 at 19:27
    
@Ok. I'm going to start a new thread. But is there a way I can search for the id_rsa text so I don't have to read countless lines? –  Chakotay Nov 8 '13 at 19:33

2 Answers 2

up vote 2 down vote accepted

add -P 2222 immediately after scp before the location parameters

scp -P 2222 ~/.ssh/id_dsa.pub username@mywebpage.com:.ssh/authorized_keys
share|improve this answer
    
@X Tian That worked to get my 1 step further. Thanks. –  Chakotay Nov 8 '13 at 18:32
    
It then transferred the file. However I had to create the directory myself before it would transfer. Now it's supposed to ask my for my passphrase instead of my password. It didn't do this so they tutorial said to run these commands. chmod 700 ~/.ssh chmod 600 ~/.ssh/authorized_keys. But when I login it still asks for my password and not my passphrase. What can the problem be? And also I still can't find the .ssh folder, is it supposed to be hidden? –  Chakotay Nov 8 '13 at 18:35
    
I think this can also be done using the command ssh-copy-id that's often bundled on Linux systems. –  slm Nov 8 '13 at 22:40

But when I look in that folder I don't see the .ssh folder. Is this done for security reasons and it's supposed to be hidden?

In *nix, directories and files whose names start with a . are typically hidden by default from the user. You can see them with ls by doing ls -a.

Try, putting the -P 2222 before the files on the command line. You must use a capital P, i.e., -P — lowercase p is used for something else. See man scp.

scp uses ssh to do the data transfer securely, which is why you need to specify the SSH port (since you're running it on a non-standard port).

share|improve this answer
    
Thanks for that information. –  Chakotay Nov 8 '13 at 18:43
    
lower-case p is used for ssh, no? Could you please take a look at my edit to my original question? I'm a bit stuck again. –  Chakotay Nov 8 '13 at 19:03
    
Yes, for ssh, -p is for port. However, in scp, -P is the port. -p, in scp, is "Preserves modification times, access times, and modes from the original file." –  Thanatos Nov 8 '13 at 19:10

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.