Solved

How to set up password-less SFTP between two Linux machines using public key?

Posted on 2012-03-19
7
926 Views
Last Modified: 2012-08-13
I have two Linux machines, LinMacA (192.168.28.241) and LinMacB (192.168.28.242).

I transfer files using SFTP from LinMacB to LinMacA, using usernames and passwords.

But now I want to establish a password-less SFTP using a public key so that LinMacB can transfer files to LinMacA through SFTP without having the need to enter a password.

How do I create a public key and for which machine should I create it for?

I generated a private/public key pair using PuTTY Key Generator on my Windows machine but I'm not quite sure what are the next steps.
0
Comment
Question by:killdurst
  • 2
  • 2
  • 2
  • +1
7 Comments
 
LVL 10

Accepted Solution

by:
MadShiva earned 250 total points
ID: 37736647
Dear,

Please read this tutorial.

SFTP SSH KEYS

If you have any problem about the setup don't hesitate to ask.

Regards
0
 
LVL 6

Assisted Solution

by:torakeshb
torakeshb earned 125 total points
ID: 37736681
0
 
LVL 1

Author Comment

by:killdurst
ID: 37736722
I've followed the ask leo steps but when I tried to execute the following command on LinMacB...

sftp useronlinmaca@192.168.28.241

I'm still prompted to enter a password.

I've ensured that RSAAuthentication and PubkeyAuthentication in sshd_config is uncommented and their values are "yes".

I've generated the private and public keys on LinMacB.

On LinMacA, at /home/useronlinmaca/.ssh, using VI, I created a file called "authorized_keys" and pasted the contents of "id_rsa.pub".

I've even restarted the SSH servvice by executing "service sshd restart" on LinMacA.
0
Flexible connectivity for any environment

The KE6900 series can extend and deploy computers with high definition displays across multiple stations in a variety of applications that suit any environment. Expand computer use to stations across multiple rooms with dynamic access.

 
LVL 6

Expert Comment

by:torakeshb
ID: 37736736
This is for SSH and SCP, try SCP and see whether you are able to do a  password less login
0
 
LVL 10

Expert Comment

by:MadShiva
ID: 37736999
Dear,

Check the follow :

You should put the key on the LinMacB and using the useronlinmacB@server2

You should also not enter passphrase when you have created the key.

Regards
0
 
LVL 19

Assisted Solution

by:Gabriel Orozco
Gabriel Orozco earned 125 total points
ID: 37740665
It is as described above, but I will try to put here the steps:

1. create the key on the LinMacB server, as the user doing the SFTP
    ssh-keygen   (follow instructions. leave all as default, no password, use RSA Key)
2. copy your ~/.ssh/id_rsa.pub from LinMacB to LinMacA, and place it there on the user's home directory under his ~/.ssh and rename the file to authorized_keys
That's it.

Troubleshooting:
If you are still prompted for the user/password, it may be due:
1. your .ssh directory permissions should be 700 or ssh will not use the keys because they are insecure.
2. you do not have the ssh server correctly configured.

To test, you should be able to ssh from LinMacB to LinMacA without having to enter a password. If this works, then SFTP should work too.
0
 
LVL 1

Author Comment

by:killdurst
ID: 37740823
Got it to work! Turns out to be some permissions issue. Thanks everyone, will distribute the points now...
0

Featured Post

Free learning courses: Active Directory Deep Dive

Get a firm grasp on your IT environment when you learn Active Directory best practices with Veeam! Watch all, or choose any amount, of this three-part webinar series to improve your skills. From the basics to virtualization and backup, we got you covered.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
linux SFTP 8 61
FTP'ing Huge files ... How to ? FTP in segments -or- pick up ftp where you left off 5 56
Check for Linux process in script 7 49
LINUX Field Separators 7 38
In 2017, ransomware will become so virulent and widespread that if you aren’t a victim yourself, you will know someone who is.
Businesses who process credit card payments have to adhere to PCI Compliance standards. Here’s why that’s important.
Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

828 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question