Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

For development tests, I need to setup an SFTP server. So I want to know if it's possible to use the same machine as the client and the server. I tried and I keep getting this error:

> Permission denied (publickey).
> Connection closed

and by running ssh -v agharroud@localhost i get :

> OpenSSH_3.8.1p1,OpenSSL 0.9.7d 17 Mar 
> debug1: Reading configuration data /etc/ssh_config 
> debug1: Connecting to localhost [127.0.0.1] port 22.
> debug1: Connection established.   
> debug1: identity file /home/agharroud/.ssh/identity type -1
> debug1: identity file /home/agharroud/.ssh/id_rsa type 1
> debug1: identity file /home/agharroud/.ssh/id_dsa type -1
> debug1: Remote protocol version 2.0, remote software version OpenSSH_3.8.1p1 
> debug1: match: OpenSSH_3.8.1p1 pat OpenSSH* 
> debug1: Enabling compatibility mode for protocol 2.0 
> debug1: Local version string SSH-2.0-OpenSSH_3.8.1p1 
> debug1: SSH2_MSG_KEXINIT sent 
> debug1: SSH2_MSG_KEXINIT received 
> debug1: kex:server->client aes128-cbc hmac-md5 none 
> debug1: kex: client->server aes128-cbc 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 'localhost' is known and matches the RSA host key. 
> debug1: Found key in /home/agharroud/.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: SSH2_MSG_SERVICE_REQUEST sent
> debug1: SSH2_MSG_SERVICE_ACCEPT
> received
> 
>                         ****USAGE WARNING****
> 
> This is a private computer system. This computer system, including all
> related equipment, networks, and network devices (specifically
> including Internet access) are provided only for authorized use. This
> computer system may be monitored for all lawful purposes, including to
> ensure that its use is authorized, for management of the system, to
> facilitate protection against unauthorized access, and to verify
> security procedures, survivability, and operational security. Monitoring
> includes active attacks by authorized entities to test or verify the
> security of this system. During monitoring, information may be
> examined, recorded, copied and used for authorized purposes. All
> information, including personal information, placed or sent over this
> system may be monitored.
> 
> Use of this computer system, authorized or unauthorized,
> constitutes consent to monitoring of this system. Unauthorized use may
> subject you to criminal prosecution. Evidence of unauthorized use collected
> during monitoring may be used for administrative, criminal, or other
> adverse action. Use of this system constitutes consent to monitoring for
> these purposes.
> 
> debug1: Authentications that can continue: publickey 
> debug1: Next authentication method: publickey
> debug1: Trying private key:/home/agharroud/.ssh/identity
> debug1: Offering public key:/home/agharroud/.ssh/id_rsa
> debug1:Authentications that can continue:publickey 
> debug1: Trying private key:/home/agharroud/.ssh/id_dsa
> debug1: No more authentication methods to try. 
> Permission denied (publickey).

Any ideas about the problem ? thanks !

share|improve this question
    
what system are you on? what does your sshd_config look like? –  lepole Apr 26 '10 at 14:11
    
i'm on windows xp machine and i change these parameters : > HostKey /etc/ssh_host_rsa_key > HostKey /etc/ssh_host_dsa_key > RSAAuthentication no > PubkeyAuthentication yes > AuthorizedKeysFile .ssh/authorized_keys > PasswordAuthentication no > ChallengeResponseAuthentication no –  achraf Apr 27 '10 at 7:21
add comment

1 Answer

Yes, it is possible and should work out of the box (as long as you have ssh and sshd, which appears that you do).

Without looking at your config I would speculate that either your password authentication is disabled, or your private key has incorrect permissions. /home/agharroud/.ssh/id_rsa and /home/agharroud/.ssh/id_dsa should have 600 permissions, if they exist.

share|improve this answer
    
Also, the entire ~/.ssh directory should have those restrictive permissions –  Matt Simmons Apr 26 '10 at 15:29
    
i just have id_rsa so i changed its permissions to 600 but still have : "Permission denied (publickey)" error ! you know where to put the pub key and the authorized_key file ? because i'm a not sure about to folder. thanks –  achraf Apr 26 '10 at 15:37
    
@achraf: your public key goes into remote user's home directory .ssh/authorized_keys file. just append it to the end of the file. –  solefald Apr 26 '10 at 16:15
    
ok that what i did and i wich directory should i put the other key on server side ? –  achraf Apr 27 '10 at 7:45
    
@achraf: on the server side the key has to be in ~/.ssh directory of a user you are trying to SSH as, so if i SSH as local_user@server1 to root@server2, your private key stays in ~local_user/.ssh/id_dsa (or id_rsa) and then on the remote server you put your id_dsa.pub into ~root/.ssh/authorized_keys –  solefald Apr 27 '10 at 15:32
add comment

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.