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.
- Where am I making a mistake?
- How can I give a username and password in command so that it wont ask password?
Update:1
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.
I want to copy file from source to destination using any protocol. change the permission
[remote-host]$ chmod 700 ~/.ssh [remote-host]$ chmod 600 ~/.ssh/authorized_key
-
2The first line of your question says, "...want to use FTP." Why are you using SCP and SSH? These are not the same thing.D34DM347– D34DM3472015年10月01日 12:59:48 +00:00Commented Oct 1, 2015 at 12:59
3 Answers 3
- You probably don't have permission on /home/Desktop on remote server, you may want to try /home/username_for_target_machine/Desktop
- No, I don't think so. But you can Google for "ssh Public Key Authentication"
-
Please see the updated questionVarun– Varun2015年10月01日 12:10:04 +00:00Commented Oct 1, 2015 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:
Remove the entry you added to the remote
authorized_keysfile.Fix the permissions on the remote host:
[remote-host]$ chmod 700 ~/.ssh/ [remote-host]$ chmod 600 ~/.ssh/authorised_keysFrom the local host, copy your key to the remote:
[local-host]$ ssh-copy-id -i ~/.ssh/id_rsa.pub user@ipaddress_of_remote-hostTry logging in again
[local-host]$ ssh jsmith@ipaddress_of_remote-hostIt 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 mentioned3rd 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_keysto make sure we haven't added extra keys that you weren't expecting.Varun– Varun2015年10月01日 13:24:50 +00:00Commented Oct 1, 2015 at 13:24 -
when I tried 4th step
ssh qaserver4@remote-hostdind work. tried sshqaserver4@ip_address_of_remote_machineits ask for password, when I provided the password. it got connected with target machine. But still its is asking for the passwordVarun– Varun2015年10月01日 13:31:33 +00:00Commented Oct 1, 2015 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– terdon2015年10月01日 13:36:40 +00:00Commented Oct 1, 2015 at 13:36
-
I tried step 5 and i save ipaddress with my hostname. When I tried this
ssh qaserver4@qaserver4The 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 qaserver3but it still asking for the passwordVarun– Varun2015年10月01日 13:43:40 +00:00Commented Oct 1, 2015 at 13:43 -
@varun is the username the same as the server name? Why are you doing
ssh qaserver4@qaserver4? Shouldn't that bessh varun@qaserver4? Anyway, that error is because i) there is noqaserver4user onqaserveror ii) you are using the wrong password.terdon– terdon2015年10月01日 13:45:30 +00:00Commented Oct 1, 2015 at 13:45
I think you haven't configure your FTP as it is asking for password so just check this link :
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
#
listen=YES
# Enable anonymous access to FTP server
anonymous_enable=YES
#
local_enable=YES
# Enable write access
write_enable=YES
anon_upload_enable=YES
anon_mkdir_write_enable=YES
dirmessage_enable=YES
# Write log file
xferlog_enable=YES
connect_from_port_20=YES
chown_uploads=YES
chown_username=ftp
ftpd_banner=Welcome to FTP service.
anon_root=/srv/ftp
Grant Restricted Permissions to FTP Users (Home Only)
chroot_local_users=YES
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 questionVarun– Varun2015年10月01日 12:11:18 +00:00Commented Oct 1, 2015 at 12:11