3 Steps to Perform SSH Login Without Password Using ssh-keygen & ssh-copy-id

95

You can login to a remote Linux server without entering password in 3 simple steps using ssky-keygen and ssh-copy-id as explained in this article.

ssh-keygen creates the public and private keys. ssh-copy-id copies the local-host’s public key to the remote-host’s authorized_keys file. ssh-copy-id also assigns proper permission to the remote-host’s home, ~/.ssh, and ~/.ssh/authorized_keys.

This article also explains 3 minor annoyances of using ssh-copy-id and how to use ssh-copy-id along with ssh-agent.

Step 1: Create public and private keys using ssh-key-gen on local-host

jsmith@local-host$ [Note: You are on local-host here]

jsmith@local-host$ ssh-keygen
Generating public/private rsa key pair.
Enter file in which to save the key (/home/jsmith/.ssh/id_rsa):[Enter key]
Enter passphrase (empty for no passphrase): [Press enter key]
Enter same passphrase again: [Pess enter key]
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:
33:b3:fe:af:95:95:18:11:31:d5:de:96:2f:f2:35:f9 jsmith@local-host

Step 2: Copy the public key to remote-host using ssh-copy-id

jsmith@local-host$ ssh-copy-id -i ~/.ssh/id_rsa.pub remote-host
jsmith@remote-host's password:
Now try logging into the machine, with "ssh 'remote-host'", and check in:

.ssh/authorized_keys

to make sure we haven't added extra keys that you weren't expecting.

Note: ssh-copy-id appends the keys to the remote-host’s .ssh/authorized_key.

Step 3: Login to remote-host without entering the password

jsmith@local-host$ ssh remote-host
Last login: Sun Nov 16 17:22:33 2008 from 192.168.1.2
[Note: SSH did not ask for password.]

jsmith@remote-host$ [Note: You are on remote-host here]

The above 3 simple steps should get the job done in most cases.

We also discussed earlier in detail about performing SSH and SCP from openSSH to openSSH without entering password.

If you are using SSH2, we discussed earlier about performing SSH and SCP without password from SSH2 to SSH2 , from OpenSSH to SSH2 and from SSH2 to OpenSSH.

Using ssh-copy-id along with the ssh-add/ssh-agent

When no value is passed for the option -i and If ~/.ssh/identity.pub is not available, ssh-copy-id will display the following error message.

jsmith@local-host$ ssh-copy-id -i remote-host
/usr/bin/ssh-copy-id: ERROR: No identities found

If you have loaded keys to the ssh-agent using the ssh-add, then ssh-copy-id will get the keys from the ssh-agent to copy to the remote-host. i.e, it copies the keys provided by ssh-add -L command to the remote-host, when you don’t pass option -i to the ssh-copy-id.

jsmith@local-host$ ssh-agent $SHELL

jsmith@local-host$ ssh-add -L
The agent has no identities.

jsmith@local-host$ ssh-add
Identity added: /home/jsmith/.ssh/id_rsa (/home/jsmith/.ssh/id_rsa)

jsmith@local-host$ ssh-add -L
ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAsJIEILxftj8aSxMa3d8t6JvM79DyBV
aHrtPhTYpq7kIEMUNzApnyxsHpH1tQ/Ow== /home/jsmith/.ssh/id_rsa

jsmith@local-host$ ssh-copy-id -i remote-host
jsmith@remote-host's password:
Now try logging into the machine, with "ssh 'remote-host'", and check in:

.ssh/authorized_keys

to make sure we haven't added extra keys that you weren't expecting.
[Note: This has added the key displayed by ssh-add -L]

Three Minor Annoyances of ssh-copy-id

Following are few minor annoyances of the ssh-copy-id.

Default public key: ssh-copy-id uses ~/.ssh/identity.pub as the default public key file (i.e when no value is passed to option -i). Instead, I wish it uses id_dsa.pub, or id_rsa.pub, or identity.pub as default keys. i.e If any one of them exist, it should copy that to the remote-host. If two or three of them exist, it should copy identity.pub as default.
The agent has no identities: When the ssh-agent is running and the ssh-add -L returns “The agent has no identities” (i.e no keys are added to the ssh-agent), the ssh-copy-id will still copy the message “The agent has no identities” to the remote-host’s authorized_keys entry.
Duplicate entry in authorized_keys: I wish ssh-copy-id validates duplicate entry on the remote-host’s authorized_keys. If you execute ssh-copy-id multiple times on the local-host, it will keep appending the same key on the remote-host’s authorized_keys file without checking for duplicates. Even with duplicate entries everything works as expected. But, I would like to have my authorized_keys file clutter free.

If you like this article, please bookmark it on Delicious and Stumble it.

246 评论

  1. 增达网:
    ——————————
    终生只需99元,让百万人每天浏览你的广告,每次浏览十秒时间。

    终生只需99元,免费下载群发软件,无使用限制,全部是破解版。

    终生只需99元,让你什么不干躺着就赚钱,上线替下线发展会员。
    ——————————
    群发软件免费下,无限广告免费发,

    百万流量免费享,十级提成免费拿。
    ——————————
    注册网址:

    http://www.wo.zengda.xin/
    ——————————
    免费会员,不花钱,照样赚
    ——————————

  2. 增达网:
    ——————————
    终生只需99元,让百万人每天浏览你的广告,每次浏览十秒时间。

    终生只需99元,免费下载群发软件,无使用限制,全部是破解版。

    终生只需99元,让你什么不干躺着就赚钱,上线替下线发展会员。
    ——————————
    群发软件免费下,无限广告免费发,

    百万流量免费享,十级提成免费拿。
    ——————————
    注册网址:

    http://www.wo.zengda.xin/
    ——————————

  3. 天涯有个朋友,心就会飞翔;心中有个希望,笑就会清爽;人生有个缘分,梦就会绵长;时常有个问候,友谊就会起航。

  4. I want to show some thanks to you just for bailing me out of such a difficulty. Right after exploring throughout the the web and getting tips that were not beneficial, I figured my entire life was gone. Being alive without the strategies to the issues you’ve fixed by means of your good short article is a serious case, and the ones that could have negatively affected my career if I hadn’t noticed the blog. Your main competence and kindness in maneuvering everything was priceless. I don’t know what I would’ve done if I hadn’t encountered such a step like this. I’m able to at this time relish my future. Thanks for your time so much for the high quality and results-oriented guide. I will not hesitate to refer the website to anyone who should receive counselling on this issue.

  5. I really wanted to post a brief message in order to appreciate you for all of the wonderful tricks you are writing on this site. My particularly long internet look up has now been compensated with awesome points to write about with my close friends. I ‘d express that many of us site visitors are unquestionably blessed to exist in a very good website with very many lovely professionals with very beneficial guidelines. I feel very much happy to have used the web site and look forward to tons of more exciting times reading here. Thank you once more for a lot of things.

  6. That is the right blog for anyone who wants to seek out out about this topic. You notice so much its virtually exhausting to argue with you (not that I really would need匟aHa). You definitely put a new spin on a subject thats been written about for years. Great stuff, simply great!

  7. I precisely had to say thanks yet again. I am not sure the things that I would have created without the type of basics revealed by you about my question. It had become the horrifying matter in my circumstances, nevertheless seeing this specialised technique you treated the issue took me to weep with fulfillment. Extremely thankful for this guidance and in addition trust you find out what a powerful job you were doing educating other individuals by way of a blog. I am certain you’ve never got to know all of us.

  8. After examine just a few of the weblog posts in your website now, and I actually like your method of blogging. I bookmarked it to my bookmark web site list and can be checking again soon. Pls take a look at my website online as effectively and let me know what you think.

  9. You made some first rate factors there. I seemed on the web for the problem and found most individuals will go together with along with your website.

  10. I would like to express some appreciation to the writer for bailing me out of such a crisis. As a result of surfing through the internet and seeing basics which are not beneficial, I figured my life was done. Being alive without the presence of strategies to the difficulties you have resolved by way of your good guideline is a crucial case, and ones that would have badly affected my career if I hadn’t encountered your site. Your competence and kindness in taking care of almost everything was tremendous. I’m not sure what I would have done if I hadn’t come upon such a solution like this. I’m able to at this time relish my future. Thanks a lot so much for your reliable and sensible guide. I will not be reluctant to refer your blog to anybody who would need guidance about this topic.

  11. I just wanted to send a quick word to express gratitude to you for some of the magnificent tips and hints you are placing here. My particularly long internet search has at the end of the day been honored with reliable facts and strategies to go over with my company. I would point out that we site visitors actually are unquestionably lucky to live in a decent site with very many marvellous people with very helpful principles. I feel extremely happy to have seen your web page and look forward to many more pleasurable minutes reading here. Thank you again for all the details.

  12. you are in point of fact a just right webmaster. The site loading
    speed is amazing. It sort of feels that you are doing any
    distinctive trick. Also, The contents are masterwork.
    you have performed a fantastic activity on this matter!

  13. Hello! Would you mind if I share your blog with my facebook group?
    There’s a lot of people that I think would really appreciate your content.

    Please let me know. Thanks

  14. Hi there! I know this is kinda off topic but I was
    wondering which blog platform are you using for this website?
    I’m getting sick and tired of WordPress because I’ve had problems with hackers and
    I’m looking at options for another platform. I would be great if you could point me in the direction of a good platform.

  15. I have to show appreciation to you just for bailing me out of such a predicament. Right after researching through the search engines and getting tricks which were not powerful, I believed my entire life was over. Being alive without the presence of answers to the difficulties you’ve resolved by means of your short post is a serious case, as well as the kind that would have adversely damaged my career if I had not discovered your website. Your actual knowledge and kindness in dealing with the whole lot was vital. I’m not sure what I would have done if I hadn’t encountered such a solution like this. It’s possible to at this time relish my future. Thanks very much for this specialized and effective help. I will not think twice to propose your blog post to any individual who would need support on this issue.

  16. An impressive share, I just given this onto a colleague who was doing a bit evaluation on this. And he in truth bought me breakfast as a result of I discovered it for him.. smile. So let me reword that: Thnx for the deal with! However yeah Thnkx for spending the time to discuss this, I really feel strongly about it and love reading more on this topic. If doable, as you change into expertise, would you mind updating your blog with more particulars? It is highly helpful for me. Huge thumb up for this weblog submit!

  17. I wanted to create you this little bit of remark so as to give thanks yet again for all the fantastic knowledge you have contributed here. It is surprisingly open-handed with people like you to allow unreservedly all many individuals would’ve advertised as an ebook to earn some dough for their own end, chiefly since you could have done it if you wanted. These tactics as well acted like the fantastic way to realize that some people have the same zeal much like my personal own to realize great deal more when it comes to this matter. I’m sure there are millions of more pleasant instances in the future for those who look into your website.

  18. Can I just say what a aid to seek out somebody who actually knows what theyre speaking about on the internet. You definitely know the way to deliver a problem to gentle and make it important. More folks have to learn this and understand this aspect of the story. I cant consider youre no more in style since you positively have the gift.

  19. I really wanted to send a brief note to be able to express gratitude to you for these lovely tactics you are posting on this site. My prolonged internet lookup has at the end of the day been compensated with good tips to exchange with my colleagues. I would admit that we visitors actually are really lucky to live in a wonderful community with so many brilliant individuals with great concepts. I feel very privileged to have used your entire website page and look forward to plenty of more fabulous moments reading here. Thanks once more for everything.

  20. I抦 impressed, I need to say. Actually not often do I encounter a weblog that抯 each educative and entertaining, and let me tell you, you will have hit the nail on the head. Your concept is outstanding; the issue is something that not sufficient individuals are talking intelligently about. I am very glad that I stumbled across this in my seek for one thing referring to this.

  21. I definitely wanted to send a quick remark to appreciate you for all the unique information you are showing on this website. My prolonged internet lookup has at the end of the day been recognized with reputable suggestions to exchange with my guests. I ‘d repeat that we visitors actually are very much lucky to live in a fine network with so many marvellous people with useful solutions. I feel very much privileged to have seen your webpage and look forward to some more fun minutes reading here. Thanks once more for all the details.

  22. Good V I should definitely pronounce, impressed with your website. I had no trouble navigating through all tabs and related information ended up being truly simple to do to access. I recently found what I hoped for before you know it at all. Reasonably unusual. Is likely to appreciate it for those who add forums or something, website theme . a tones way for your customer to communicate. Excellent task..

  23. Definitely believe that which you said. Your favorite reason appeared to be on the net the simplest thing to be aware of.
    I say to you, I definitely get annoyed while people think about worries that they
    plainly don’t know about. You managed to hit the nail upon the
    top as well as defined out the whole thing without having side effect , people
    can take a signal. Will probably be back to get more. Thanks

  24. Woah! I’m really loving the template/theme of this blog.
    It’s simple, yet effective. A lot of times it’s tough to get
    that “perfect balance” between usability and visual appeal.

    I must say you have done a amazing job with this.
    In addition, the blog loads extremely fast for me on Chrome.
    Excellent Blog!

  25. I would like to express appreciation to this writer for rescuing me from this particular condition. Right after researching through the online world and obtaining concepts which are not pleasant, I figured my entire life was over. Being alive without the answers to the problems you’ve resolved by way of the short post is a serious case, and ones that would have in a wrong way affected my entire career if I had not come across your web site. The know-how and kindness in touching almost everything was useful. I don’t know what I would’ve done if I had not come across such a stuff like this. It’s possible to now look forward to my future. Thanks so much for your reliable and results-oriented help. I won’t be reluctant to refer your site to anyone who requires recommendations on this problem.

  26. wonderful publish, very informative. I ponder why the other specialists of this sector do not notice this.
    You should proceed your writing. I’m confident, you
    have a great readers’ base already!

  27. Thank you for some other excellent article.

    The place else may just anybody get that kind of information in such a perfect approach of writing?

    I’ve a presentation subsequent week, and I’m at the look for such information.

  28. You’re so awesome! I don’t suppose I’ve truly read through anything like that before.
    So great to find somebody with original thoughts on this subject matter.
    Really.. thank you for starting this up. This website is something that is needed
    on the web, someone with some originality!

  29. Hello there, just became aware of your blog through
    Google, and found that it is truly informative. I’m gonna watch out for brussels.
    I’ll be grateful if you continue this in future.
    A lot of people will be benefited from your writing.
    Cheers!

  30. Fantastic items from you, man. I’ve take into accout your stuff previous to and you are just
    extremely great. I actually like what you have bought here, really like what you are saying and
    the way in which you say it. You make it entertaining and you continue to care for to keep it smart.
    I can’t wait to learn much more from you. This is really
    a wonderful site.

  31. I think this is among the most important info for me.
    And i’m glad reading your article. But want to remark on few
    general things, The site style is ideal, the articles is really great : D.
    Good job, cheers

  32. Wow, awesome blog layout! How long have you been blogging for?
    you made blogging look easy. The overall look of
    your web site is excellent, let alone the content!

  33. I blog frequently and I genuinely appreciate your information. This great article has truly peaked my interest.
    I will bookmark your site and keep checking for new details about once a week.

    I opted in for your RSS feed too.

  34. It’s really a nice and useful piece of info. I am happy that you shared this useful info with us.
    Please keep us informed like this. Thank you for sharing.

  35. Aw, this was an extremely nice post. Taking the time and actual effort to produce a really good article… but what can I
    say… I procrastinate a lot and never manage to get anything done.

  36. It’s wonderful that you are getting ideas from this article as well as
    from our argument made at this time.

  37. Excellent goods from you, man. I have understand your stuff previous to and
    you are just too great. I actually like what you have acquired here, really like what you’re saying
    and the way in which you say it. You make it entertaining and you still care for to keep it wise.
    I can’t wait to read far more from you. This is really a wonderful site.

  38. Excellent post. Keep writing such kind of info on your page.

    Im really impressed by your site.
    Hello there, You have done an excellent job. I’ll definitely digg it and personally suggest to my friends.

    I am confident they will be benefited from this web site.

  39. Nice blog here! Also your website quite a bit up fast!
    What host are you the usage of? Can I get your affiliate hyperlink in your host?
    I desire my web site loaded up as fast as yours lol

  40. I enjoy what you guys tend to be up too. This
    sort of clever work and reporting! Keep up the great works
    guyhs I’ve incorporated you guys to my blogroll.

  41. It’s reaslly a great and helpful piece of information. I am satisfied that you shard this useful info with us.
    Plerase stay us infformed like this. Thank yyou for sharing.

  42. Very good blog! Do you have any suggestions for aspiring writers?
    I’m hoping to start my own site soon but I’m a little lost on everything.
    Would you suggest starting with a free platform like WordPress or
    go for a paid option? There are so many choices out
    there that I’m completely overwhelmed .. Any recommendations?
    Cheers!

  43. Today, while I wass at work, my sister stole my iphone and tested to see if it can survive a thirty foott drop,
    just soo she can be a youtube sensation. My apple ipad is now destroyed and she has 83 views.I know this
    is totally off topic but I had to share it with someone!

  44. We absolutely love your blog and find most of your post’s to be what precisely I’m looking
    for. Would you offer guest writers to write content for
    you? I wouldn’t mind producing a post or elaborating on a number of
    the subjects you write in relation to here. Again, awesome weblog!

  45. Terrific work! That is the kind of info that are supposed
    to be shared across the net. Disgrace on Google
    for not positioning this put up upper! Come on over and
    discuss with my website . Thank you =)

  46. Good day! I know this is kind of off topic but I was wondering which blog platform are you
    using for this site? I’m getting fed up of WordPress because I’ve had issues
    with hackers and I’m looking at options for another platform.
    I would be awesome if you could point me in the direction of a good platform.

  47. I believe this is among the most vital information for me.
    And i am happy studying your article. But should commentary on few general things, The
    web site taste is great, the articles is in point of fact nice : D.
    Just right job, cheers

  48. I just want to mention I’m beginner to blogs and absolutely enjoyed this page. Very likely I’m going to bookmark your website . You certainly have remarkable well written articles. Cheers for sharing your web-site.

  49. It’s a pity you don’t have a donate button! I’d certainly donate to this outstanding blog!
    I guess for now i’ll settle for bookmarking and adding your RSS feed to my Google account.
    I look forward to fresh updates and will talk about this website with my Facebook
    group. Talk soon!

  50. Remarkable things here. I am very glad to look your post.
    Thank you so much and I’m having a look ahead to touch
    you. Will you kindly drop me a mail?

  51. Вы не правы. Могу отстоять свою позицию.


    Скажите мне, пожалуйста – где я могу об этом прочитать? скачать fifa 15 mediaget, fifa 15 русская версия скачать торрент и официальный сайт ea sports скачать fifa 15 repack через торрент

发表回复

Please enter your comment!
Please enter your name here