Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

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

Posted on 2012-03-19
7
Medium Priority
?
956 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
  • 2
  • +1
7 Comments
 
LVL 10

Accepted Solution

by:
Tobias earned 1000 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 7

Assisted Solution

by:torakeshb
torakeshb earned 500 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
Learn Veeam advantages over legacy backup

Every day, more and more legacy backup customers switch to Veeam. Technologies designed for the client-server era cannot restore any IT service running in the hybrid cloud within seconds. Learn top Veeam advantages over legacy backup and get Veeam for the price of your renewal

 
LVL 7

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:Tobias
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 500 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

Moving data to the cloud? Find out if you’re ready

Before moving to the cloud, it is important to carefully define your db needs, plan for the migration & understand prod. environment. This wp explains how to define what you need from a cloud provider, plan for the migration & what putting a cloud solution into practice entails.

Question has a verified solution.

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

In the first part of this tutorial we will cover the prerequisites for installing SQL Server vNext on Linux.
The recent Petya-like ransomware attack served a big blow to hundreds of banks, corporations and government offices The Acronis blog takes a closer look at this damaging worm to see what’s behind it – and offers up tips on how you can safeguard your…
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.:
If you're a developer or IT admin, you’re probably tasked with managing multiple websites, servers, applications, and levels of security on a daily basis. While this can be extremely time consuming, it can also be frustrating when systems aren't wor…
Suggested Courses

721 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