Monday , December 10 2018
Trang chủ / Linux / SSH Per-Host Configuration

SSH Per-Host Configuration

And the “new trick of the week” award goes to… SSH configuration files.

I’ve been an OpenSSH user for a LONG, LONG time. I’ve used lots of different configuration, and connected to probably hundreds of hosts. No, I don’t use a GUI interface. Yes, I prefer scp to just about any other remote copying tool. I pretty much thought I knew it all.

Turns out there was an elephant-sized hole in my SSH knowledge. One of my colleagues at Palantir.net showed me his .ssh/config file.

Now, several years ago I put a few directives in one of those things, but thought nothing else of it. But a split-second glance at his configuration made me drool. He had almost a dozen hosts configured in there, allowing him to type things like this:

1
$ ssh example

Meanwhile, I was typing:

1
$ ssh butcher@example.com -i my_key_file

And my error-prone fingers rarely get the right username, hostname, and identity file.

Heading over to man’s best friend (that’d be man ssh_config), I quickly loaded up my .ssh/config file with entries that look like this:

1
2
3
4
5
6
7
8
9
10
Host dev
    HostName dev.example.com
    Port 22000
    User fooey
    IdentityFile ~/.ssh/devkey01

Host github
    HostName 210.188.199.181
    User git01
    IdentityFile ~/.ssh/github.key

Now I can connect to the first one with a simple

1
$ ssh dev

, after which I will be prompted for a password. Likewise, for the second one,

1
$ ssh github

I wish you success!

About admin

Check Also

Hướng dẫn backup full user trong VPS DirectAdmin

Với dịch vụ vps bạn có thể chủ động việc backup dữ liệu của các …

9 Bình luận

  1. Reanidg posts like this make surfing such a pleasure

  2. I simply want to tell you that I am just beginner to blogging and really liked your web site. Almost certainly I’m want to bookmark your site . You absolutely have very good article content. Kudos for sharing with us your web site.

  3. I’ve been absent for some time, but now I remember why I used to love this web site. Thank you, I’ll try and check back more often. How frequently you update your web site?

  4. I genuinely enjoy reading on this web site , it contains excellent content . “Beauty in things exist in the mind which contemplates them.” by David Hume.

  5. I’m often to blogging we truly appreciate your posts. Your content has truly peaks my interest. I am about to bookmark your web internet site and preserve checking achievable details.

  6. I’m not real superb with English but I come up this actually straightforward to read .

  7. hello there and thank you for your information – I’ve certainly picked up anything new from right here. I did however expertise several technical issues using this site, since I experienced to reload the site a lot of times previous to I could get it to load correctly. I had been wondering if your web hosting is OK? Not that I’m complaining, but sluggish loading instances times will often affect your placement in google and could damage your high-quality score if ads and marketing with Adwords. Well I’m adding this RSS to my e-mail and could look out for a lot more of your respective interesting content. Make sure you update this again soon..

  8. Excellent post but I was wanting to know if you could write a litte more on this topic? I’d be very thankful if you could elaborate a little bit more. Kudos!

  9. I¡¦ve been exploring for a bit for any high quality articles or blog posts on this sort of area . Exploring in Yahoo I finally stumbled upon this site. Reading this information So i am glad to convey that I have an incredibly good uncanny feeling I found out just what I needed. I most undoubtedly will make sure to do not disregard this web site and give it a glance on a constant basis.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Đăng Ký Nhận Tin Qua Email

Nhận thông tin bổ ích về WordPress, Hosting, Thủ thuật website, Download miễn phí....và các phần quà hấp dẫn qua email.

* là bắt buộc