I want to copy a file from source machine A to destination machine B, using command and want to use ftp.

I tried this

scp /home/varun/Desktop/Test.java username_for_target_machine@ip_address_of_target_machine:/home/Desktop/

The authenticity of host 'ip_address_of_target_machine (ip_address_of_target_machine)' can't be established.
RSA key fingerprint is 4a:49:cc:9d:ab:f6:ec:4f:b2:0b:63:ef:8f:b8:76:76.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'ip_address_of_target_machine' (RSA) to the list of known hosts.
qaserve@ip_address_of_target_machine's password: 

When I give password for target machine

Permission denied, please try again.

I tried multiple time but I get the same output.

  1. Where am I making a mistake?
  2. How can I give a username and password in command so that it wont ask password?


I tried using ssh. bellow are the steps what I followed.

1. Verify that local-host and remote-host is running openSSH

OpenSSH_5.3p1, OpenSSL 1.0.1e-fips 11 Feb 2013

2. Generate key-pair on the local-host using ssh-keygen

Generating public/private rsa key pair.
Enter file in which to save the key (/home/jsmith/.ssh/id_rsa):
Enter passphrase (empty for no passphrase): 
Enter same passphrase again:
Your identification has been saved in /home/jsmith/.ssh/id_rsa.
Your public key has been saved in /home/jsmith/.ssh/id_rsa.pub.
The key fingerprint is:
31:3a:5d:dc:bc:81:81:71:be:31:2b:11:b8:e8:39:a0 jsmith@local-host

3. Install public key on the remote-host.

[remote-host]$ vi ~/.ssh/authorized_keys 
ssh-rsa ABIwAAAQEAzRPh9rWfjZ1+7Q369zsBEa7wS1RxzWR jsmith@local-host

4. Give appropriate permission to the .ssh directory on the remote-host.

[remote-host]$ chmod 755 ~/.ssh
[remote-host]$ chmod 644 ~/.ssh/authorized_keys

5. Login from the local-host to remote-host using the SSH key authentication to verify whether it works properly.

[local-host]$ ssh -l jsmith remote-host

When I run the above command I get:

ssh: connect to host remote-host port 22: Connection timed out

When I type

ssh -l ipaddress_of_remote-host remote-host

Its asking for a password : when I provide the password, it connects to the remote_host.

Why is it asking for a password again after I have registered the public key in the remote host?

Update 2: Sorry for mess.

  1. I want to copy file from source to destination using any protocol. change the permission

  2. [remote-host]$ chmod 700 ~/.ssh [remote-host]$ chmod 600 ~/.ssh/authorized_key

  • 2
    The first line of your question says, "...want to use FTP." Why are you using SCP and SSH? These are not the same thing.
    – D34DM347
    Oct 1 '15 at 12:59
  1. You probably don't have permission on /home/Desktop on remote server, you may want to try /home/username_for_target_machine/Desktop
  2. No, I don't think so. But you can Google for "ssh Public Key Authentication"
  • Please see the updated question
    – Varun
    Oct 1 '15 at 12:10

You are confusing various things here. First of all none of this has anything to do with ftp. You're using scp, not ftp. Why are you mentioning ftp? Then, you seem to be attempting to connect to the host using the IP as a username (-l gives the user name to connect as). Also, the permissions are wrong for the authorized_keys file, you need 600 and 700, not 644 and 755. Finally, that really isn't a good way to copy keys around anyway, that's what ssh-copy-id is for.

So, let's try from the beginning. Steps 1 and 2 are OK, now do this:

  1. Remove the entry you added to the remote authorized_keys file.

  2. Fix the permissions on the remote host:

    [remote-host]$ chmod 700 ~/.ssh/
    [remote-host]$ chmod 600 ~/.ssh/authorised_keys
  3. From the local host, copy your key to the remote:

    [local-host]$ ssh-copy-id -i ~/.ssh/id_rsa.pub user@ipaddress_of_remote-host
  4. Try logging in again

    [local-host]$ ssh jsmith@ipaddress_of_remote-host
  5. It looks like the host is not exporting its name to the network correctly. For a quick fix, run:

    [local-host]$ echo "ipaddress_of_remote-host hostname" | sudo tee -a /etc/hosts

    That will save the name of the host as an alias for its IP. Now, you should be able to connect with ssh user@hostname.

  • 1st step: remove the entry from authorized_keys. 2nd step : change the permission to as you mentioned 3rd step [local-host ]$ ssh-copy-id -i ~/.ssh/id_rsa.pub qaserver4@remotehost ssh: connect to host remotehost port 22: Connection timed out [local-host ]]$ ssh-copy-id -i ~/.ssh/id_rsa.pub qaserver4@ipaddressof_remotehost' qaserver4@ipaddressof_remotehost''s password: Now try logging into the machine, with "ssh 'qaserver4@ipaddressof_remotehost'", and check in: .ssh/authorized_keys to make sure we haven't added extra keys that you weren't expecting.
    – Varun
    Oct 1 '15 at 13:24
  • when I tried 4th step ssh qaserver4@remote-host dind work. tried ssh qaserver4@ip_address_of_remote_machine its ask for password, when I provided the password. it got connected with target machine. But still its is asking for the password
    – Varun
    Oct 1 '15 at 13:31
  • @varun yes, it looks like you haven't set up the host to work with hostname. See updated answer, use the IP instead of the name and see step 5 for how to use the name in future.
    – terdon
    Oct 1 '15 at 13:36
  • I tried step 5 and i save ipaddress with my hostname. When I tried this ssh qaserver4@qaserver4 The authenticity of host 'qaserver4 (ipaddress_of_target_machine)' can't be established. RSA key fingerprint is 4a:49:cc:9d:ab:f6:ec:4f:b2:0b:63:ef:8f:b8:76:76. Are you sure you want to continue connecting (yes/no)? yes Warning: Permanently added 'qaserver4' (RSA) to the list of known hosts. qaserver4@qaserver4's password: Permission denied, please try again. qaserver4@qaserver4's password: Last login: Wed Oct 7 17:58:58 2015 from qaserver3 but it still asking for the password
    – Varun
    Oct 1 '15 at 13:43
  • @varun is the username the same as the server name? Why are you doing ssh qaserver4@qaserver4? Shouldn't that be ssh varun@qaserver4? Anyway, that error is because i) there is no qaserver4 user on qaserver or ii) you are using the wrong password.
    – terdon
    Oct 1 '15 at 13:45

I think you haven't configure your FTP as it is asking for password so just check this link :

1) http://www.mpipks-dresden.mpg.de/~mueller/docs/suse10.2/html/opensuse-manual_en/manual/sec.filetrans.copy.html

To configure an FTP server, proceed as follows:

**Prepare the FTP server:**

    Install the vsftp package.

    Open a shell, login as root and save a backup copy of /etc/vsftpd.conf:

    cp /etc/vsftpd.conf /etc/vsftpd.conf.bak

    Create an access point for anonymous FTP

    mkdir ~ftp/incoming
    chown -R ftp:ftp ~ftp/incoming

Replace the configuration files depending on the scenario you prefer (refer to the manual page of vsftpd.conf for advanced configuration options):

Allowing Anonymous Read and Write Access


    # Enable anonymous access to FTP server

    # Enable write access
    # Write log file 
    ftpd_banner=Welcome to FTP service.

Grant Restricted Permissions to FTP Users (Home Only)


Restart the FTP server:

rcvsftp start

On the client, just enter the URL ftp://HOST in your browser or FTP client. Replace HOST with either the hostname or the IP address of your server. There are many graphical user interfaces available that are suited to browse the contents of your FTP server. For a list of them, just enter FTP at the search prompt of the YaST package manager.

  • Please see the updated question
    – Varun
    Oct 1 '15 at 12:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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