Solved

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

Posted on 2012-03-19
7
920 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
Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

 
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

Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
iptables limit connection per ip correct way ? 2 93
a free alternative to cpanel? 1 58
nagios remote hosts 9 43
Coding C# in Linux 8 24
Explore the encryption capabilities built into Google Apps and how these features can help you meet privacy policy and regulatory compliance, but are not a full solution. Understand and compare the most popular email encryption services for Google A…
Envision that you are chipping away at another e-business site with a team of pundit developers and designers. Everything seems, by all accounts, to be going easily.
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.
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

911 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

Need Help in Real-Time?

Connect with top rated Experts

24 Experts available now in Live!

Get 1:1 Help Now