2

I have set up ssh to login to my remote server with no password using the steps provided in the tutorial at this URL: SSH Login With no Password.

When I try to login to the server using only ssh command:

$ ssh [email protected]

it works fine, and I am able to login without entering the password but when I try to copy files from local to remote server using scp command:

$ scp /location/to/file/localserver user@server:location/whereto/copy

it asks me to enter a password which is weird!

I also made sure that all the folders has the correct permissions as explained in the URL above.

Does anyone know how to fix this problem?

Executing: program /usr/bin/ssh host *.*.*.*, user ssadmin, command scp -v -t /home/ssadmin/nexthink_log`

OpenSSH_6.6.1, OpenSSL 1.0.1e-fips 11 Feb 2013`
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 56: Applying options for *
debug1: Connecting to *.*.*.* [*.*.*.*] port 22.
debug1: Connection established.
debug1: permanently_set_uid: 0/0
debug1: identity file /root/.ssh/id_rsa type -1
debug1: identity file /root/.ssh/id_rsa-cert type -1
debug1: identity file /root/.ssh/id_dsa type -1
debug1: identity file /root/.ssh/id_dsa-cert type -1
debug1: identity file /root/.ssh/id_ecdsa type -1
debug1: identity file /root/.ssh/id_ecdsa-cert type -1
debug1: identity file /root/.ssh/id_ed25519 type -1
debug1: identity file /root/.ssh/id_ed25519-cert type -1
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_6.6.1
debug1: Remote protocol version 2.0, remote software version OpenSSH_4.3
debug1: match: OpenSSH_4.3 pat OpenSSH_4* compat 0x00000000
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: kex: diffie-hellman-group-exchange-sha1 need=16 dh_need=16
debug1: kex: diffie-hellman-group-exchange-sha1 need=16 dh_need=16
debug1: SSH2_MSG_KEX_DH_GEX_REQUEST(1024<3072<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: Server host key: RSA **:**:**:**:**:**:**:**:**:**:**:**:**:**
debug1: Host '*.*.*.*' is known and matches the RSA host key.
debug1: Found key in /root/.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
debug1: Authentications that can continue: publickey,gssapi-with-mic,password
debug1: Next authentication method: gssapi-with-mic
debug1: Unspecified GSS failure.  Minor code may provide more information
No Kerberos credentials available (default cache: KEYRING:persistent:0)
debug1: Unspecified GSS failure.  Minor code may provide more information
No Kerberos credentials available (default cache: KEYRING:persistent:0)
debug1: Next authentication method: publickey
debug1: Trying private key: /root/.ssh/id_rsa
debug1: Trying private key: /root/.ssh/id_dsa
debug1: Trying private key: /root/.ssh/id_ecdsa
debug1: Trying private key: /root/.ssh/id_ed25519
debug1: Next authentication method: password

ssadmin@*.*.*.*'s password:
14
  • What is the exact command you're using?
    – daisy
    Apr 5, 2017 at 11:30
  • 2
    Different users?
    – phk
    Apr 5, 2017 at 11:38
  • This needs more detail. What do you mean by 'login... with no password'? Using asymmetric key authentication? With or without passphrase? With or without a key agent? Or sshpass? Or an expect script? Does your connection depend on your ~/.ssh/config (if so, post relevant parts), or are all options specified on command line (if so, provide the command line)? Apr 5, 2017 at 11:38
  • yes different users
    – SRoss
    Apr 5, 2017 at 11:51
  • 1
    @SRoss use scp -v /location/to/file/localserver user@remoteserver:location/whereto/copy to see verbose details and if you couldn't find the reason, put the output here (remove sensetive parts) you can also check /var/log/auth.log on remote server to see more details
    – PHA
    Apr 5, 2017 at 12:43

3 Answers 3

1

First login into your linux pc and generate a pair of public keys using following command.

$ ssh-keygen -t rsa

When it asks for a password just hit enter.

create a .ssh folder in your server user and in it, upload new generated public key (id_rsa.pub) on your PC under your user's .ssh directory as a file name authorized_keys.

Set the permissions:

$ ssh [email protected] "chmod 700 .ssh; chmod 640 .ssh/authorized_keys" 

And that's it!

Secure Passwordless login.

4
  • hi, thank you for your response, I already done all of that, and when i run $ ssh [email protected] ... am able to enter with no password, my issue happens when i try to copy files using "scp" from the local to the remote server, once i type in the command it ask me for the password
    – SRoss
    Apr 5, 2017 at 13:53
  • @SRoss just press enter again and see what happens. Apr 5, 2017 at 17:02
  • what do u mean press enter again, when ? if you mean after it ask me for password, then pressing enter will give me permission denied please try again and ask me for the password again
    – SRoss
    Apr 6, 2017 at 6:32
  • @SRoss did you give a blank password while creating the SSH keys? Apr 6, 2017 at 6:34
1

You can use ssh-copy-id command

$ ssh-copy-id user@hostname

This will simply add your local keys to the authorized_keys file in the remote server. Make sure you are able to use authorized keys by enabling it in sshd_config file. This way you will never be prompted for password neither in ssh or in scp.

1
  • I did and it gives me "All keys were skipped because they are already exist on the remote system"
    – SRoss
    Apr 6, 2017 at 6:27
0

When you put in the password the secure copy works?

If you get permissions denied, it may just be the location you are trying to copy to doesn't allow writes by the remote user.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .