Posts tagged with “tips”
Following up on my last 2 posts about SSH key based authentication, here's some more useful SSH commands to manage the known hosts file that I didn't know about before.
The known hosts file, located at ~/.ssh/known_hosts, is where server public keys end up when you say "yes" to accepting a host key upon connecting to a server you've never connected to before. Chances are your file is full of keys by now if you connect to a lot of different machines. If you need to remove a key for a server change or if you no longer use the server, you can easily clean it up without editing the file directly.
You can first check if the host is even in the file:
ssh-keygen -F jfro.me
This will display the entry from the file if found. You can remove it with this command:
ssh-keygen -R jfro.me
Unfortunately it's not as easy if you use non-standard ports, it has to be an exact match to the host entry in the file:
01:35 PM | Tags: ssh, sysadmin, servers, tips
ssh-keygen -R "[example.com]:1234"
So I recently switched to zsh after encouragement from a friend and wanted to share some of the possible benefits. With some help I was able to bring over some history improvements I had in bash to zsh too.
I was pointed to this blog entry that pretty much sums up some of the pros of using zsh over bash. I'm a big fan of the tab completion options available along with the auto-correction. I can do "cd public" in my home folder and it'll fix it to "cd Public".
The tab-completion is able to do a fancy menu selection too which I kind of like:
You can move the selection around the arrows or control-C to cancel out. In this case I didn't type any characters yet, "GarageBand/" is the possible selection. Hitting enter will confirm. It behaves a bit different but I'm liking it.
One thing I did like which I didn't have setup at first was the prefix history search. The idea is you type in something like "ssh" and then can cycle through your history for anything starting with that. This makes it easy to find a previous ssh connection in this example. You can bind this behavior to a key, which I would bind to the typical history cycling of up & down. The bash history blog I linked to above mentioned this in the comments and required putting it in .inputrc. With zshrc it turns out I just needed to use it's format within zshrc itself:
bindkey "\e[B" history-beginning-search-forward
bindkey "\e[A" history-beginning-search-backward
This differed from bash's commands by the -beginning- piece being added here, otherwise it uses the previous word you typed only I believe.
There's a ton of stuff to learn about zsh of course, and I don't understand half of what's in my zshrc either. But I like the benefits and hopefully will slowly learn more. What I did to start is just tweak an existing one so I'll provide mine here:
Things it has: * A list of your servers * shortcuts to push it to the listed servers * some shortcuts to setup git for a project, including the remote copy * shortcut for cloning from my GITSERVER * tons of other useful shell functions * Sets up ls to colorize listings on linux & OS X
The zshrc is based on what Nicholas Penree gave me and thanks to him for helping improve my terminal using experience! Be sure to check the top of the file for the areas to customize.
There's some things I have yet to figure out too. Some things I'd like to figure out:
- Detect OS X GUI access to set $EDITOR properly (mate -w only if we can open a GUI app)
- Track changes to zshrc through git instead of just get/pushing it randomly
- On my MBP control-A and E don't do beginning/end line like they normally do, weird!
- Actually organize things a lot better, bindkeys are everywhere, so are various functions
Tweetie 2.0 for iPhone came out recently and has a nice feature for specifying your own URL shortening service, like one that uses ButteredURLs. It's easy enough, might want to email yourself the API key from your install of ButteredURLs or visit it on the device. Then you can copy & paste it into the "Custom" option for URL shortening services in Tweetie's settings. You can view the API key when you're at the admin area.
The URL should look a little like this, replacing APIKEY with your own key:
Tweetie will replace %@ with the URL it's shortening. For more details on the custom shortening feature of Tweetie 2.0, see the developer page about it.
Also check out Tweetie 2 itself.07:23 PM | Tags: tips, php
This isn't really anything new but I finally changed my system's default location for screenshot storage. The desktop is a gross place for them to go, so much clutter! Someone pointed me at Blacktree's secrets which got me the preference I was looking for. They have a prefpane but it's not 64-bit for 10.6 yet, relaunching System Preferences is gross.
Manually setting it in terminal:
defaults write com.apple.screencapture location "~/Pictures/Screenshots"
Once that's set you have to logout to have it take affect as I was impatient first time and thought it didn't work.
This was also an excuse to write a quick blog post since I want to try to get myself to blog a bit more. Woohoo.06:12 PM | Tags: osx, tips