Take the 2-minute tour ×
Ask Different is a question and answer site for power users of Apple hardware and software. It's 100% free, no registration required.

I have been trying access a server via ssh in terminal/ Everything works when I am working on Ubuntu.

I copied the ssh key to my Mac but it always tells me Permission denied(public key) (see below).

When I'm able use secureCRT and CyberDuck, everything will work.

Once I use secureCRT to access the server, I'll be able to access it in the terminal.

Here is debug output from the connection attempt:

tracyliu:~ apple$ ssh -vT xxxx@xx.xx.xx.xx
OpenSSH_5.6p1, OpenSSL 0.9.8r 8 Feb 2011
debug1: Reading configuration data /etc/ssh_config
debug1: Applying options for *
debug1: Connecting to xx.xx.xx.xx[xx.xx.xx.xx] port 22.
debug1: Connection established.
debug1: identity file /Users/apple/.ssh/id_rsa type -1
debug1: identity file /Users/apple/.ssh/id_rsa-cert type -1
debug1: identity file /Users/apple/.ssh/id_dsa type -1
debug1: identity file /Users/apple/.ssh/id_dsa-cert type -1
debug1: Remote protocol version 2.0, remote software version OpenSSH_4.3
debug1: match: OpenSSH_4.3 pat OpenSSH_4*
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_5.6
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: server->client aes128-ctr hmac-md5 none
debug1: kex: client->server aes128-ctr hmac-md5 none
debug1: SSH2_MSG_KEX_DH_GEX_REQUEST(1024<1024<8192) sent
debug1: expecting SSH2_MSG_KEX_DH_GEX_GROUP
debug1: SSH2_MSG_KEX_DH_GEX_INIT sent
debug1: expecting SSH2_MSG_KEX_DH_GEX_REPLY
debug1: Host 'xx.xx.xx.xx' is known and matches the RSA host key.
debug1: Found key in /Users/apple/.ssh/known_hosts:1
debug1: ssh_rsa_verify: signature correct
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: SSH2_MSG_NEWKEYS received
debug1: Roaming not allowed by server
debug1: SSH2_MSG_SERVICE_REQUEST sent
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: publickey
debug1: Next authentication method: publickey
debug1: Trying private key: /Users/apple/.ssh/id_rsa
debug1: Trying private key: /Users/apple/.ssh/id_dsa
debug1: No more authentication methods to try.
Permission denied (publickey).
share|improve this question

closed as too localized by bmike Nov 13 '12 at 22:55

This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center.If this question can be reworded to fit the rules in the help center, please edit the question.

    
Did you check the permissions of the .ssh folder on both sides? It should only be readable by the owner. Please describe your setup. It is difficult to help with just: was working, is not working anymore... –  Matteo Nov 17 '11 at 6:55
    
I have made some edits, please check to make sure I haven't changed any of your meaning. Also, more detail would be great. –  Kyle Cronin Nov 17 '11 at 7:05
    
Thenaks for the output. Could you also check (post) the permissions of your ${HOME}/.ssh folders and key on both machines? ls -ld ${HOME}/.ssh; ls -l ${HOME}/.ssh/id_rsa: they should both be rw------- –  Matteo Nov 17 '11 at 7:30
    
@Matteo I check the permissions of .ssh folder ,it is rw------- and I also changed the .ssh/id_rsa to rw------- ,but it still doesn‘t work , I have tried to del the folder and made a new , "The authenticity of host 'x.x.x.x' can't be established. RSA key fingerprint is d7:35:09:62:90:5d:e7:19:bd:ba:ea:8e:7a:d3:ad:37. Are you sure you want to continue connecting (yes/no)? yes Failed to add the host to the list of known hosts (/Users/apple/.ssh/known_hosts)." –  wtracyliu Nov 17 '11 at 8:22
    
@KyleCronin thanks very much –  wtracyliu Nov 17 '11 at 8:24
show 5 more comments

2 Answers

While on your Mac machine, just generate a new SSH key to connect server.Just like Git clients, you need to create multiple Git SSH key to pull/push Git repositories.

share|improve this answer
    
You don't need a new key. You can have the same private key on multiple machines. –  Matteo Nov 17 '11 at 7:28
add comment

I've been trying to get my ssh connection from my Mac terminal to connect to my web server and realized I need to change the permissions of my private key to 600. In the process of doing that, I pulled a rookie mistake and tried a command I probably shouldn't have: chmod -v -R 600 ~/.ssh. After I did that I can no longer access my .ssh folder on my mac. I get the error permission denied. When I try this ls -l -a ~/.ssh I get this:

ls: .: Permission denied ls: ..: Permission denied ls: id_dsa: Permission denied ls: id_rsa: Permission denied ls: id_rsa.pub: Permission denied ls: known_hosts: Permission denied

Does anyone have any advice on how I can fix this folder and the keys inside it?

Thanks

share|improve this answer
add comment

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