Hide

What's this?

commandlinefu.com is the place to record those command-line gems that you return to again and again.

Delete that bloated snippets file you've been using and share your personal repository with the world. That way others can gain from your CLI wisdom and you from theirs too. All commands can be commented on, discussed and voted up or down.


If you have a new feature suggestion or find a bug, please get in touch via http://commandlinefu.uservoice.com/

Get involved!

You can sign-in using OpenID credentials, or register a traditional username and password.

First-time OpenID users will be automatically assigned a username which can be changed after signing in.

Hide

Stay in the loop…

Follow the Tweets.

Every new command is wrapped in a tweet and posted to Twitter. Following the stream is a great way of staying abreast of the latest commands. For the more discerning, there are Twitter accounts for commands that get a minimum of 3 and 10 votes - that way only the great commands get tweeted.

» http://twitter.com/commandlinefu
» http://twitter.com/commandlinefu3
» http://twitter.com/commandlinefu10

Subscribe to the feeds.

Use your favourite RSS aggregator to stay in touch with the latest commands. There are feeds mirroring the 3 Twitter streams as well as for virtually every other subset (users, tags, functions,…):

Subscribe to the feed for:

Hide

News

2011-03-12 - Confoo 2011 presentation
Slides are available from the commandlinefu presentation at Confoo 2011: http://presentations.codeinthehole.com/confoo2011/
2011-01-04 - Moderation now required for new commands
To try and put and end to the spamming, new commands require moderation before they will appear on the site.
2010-12-27 - Apologies for not banning the trolls sooner
Have been away from the interwebs over Christmas. Will be more vigilant henceforth.
2010-09-24 - OAuth and pagination problems fixed
Apologies for the delay in getting Twitter's OAuth supported. Annoying pagination gremlin also fixed.
Hide

Tags

Hide

Functions

Commands using ssh-keygen from sorted by
Terminal - Commands using ssh-keygen - 23 results
for id in `ls -1 ~/.ssh | grep -v "authorized\|known_hosts\|config\|\."` ; do echo -n "$id: " ; ssh-keygen -l -f .ssh/$id ; done
2014-04-16 14:12:20
User: drockney
Functions: echo grep id ssh-keygen
0

Find all private keys and dump their fingerprints.

diff <(ssh-keygen -y -f ~/.ssh/id_rsa) <(cut -d' ' -f1,2 ~/.ssh/id_rsa.pub)
ssh-keygen -l -f [pubkey] | cut -d ' ' -f 2 | tr -ds '\n:' ''
for HOSTTOREMOVE in $(dig +short host.domain.tld); do ssh-keygen -qR $HOSTTOREMOVE; done
ssh-keygen -R $(dig +short host.domain.tld)
2012-01-19 15:08:50
User: atoponce
Functions: dig ssh ssh-keygen
2

Quick shortcut if you know the hostname and want to save yourself one step for looking up the IP address separately.

ssh-keygen -R <thehost>
ssh-keygen -C hello@world
2011-07-06 18:02:32
User: aykut
Functions: ssh ssh-keygen
0

Now at the end of the rsa.pub file, there is our comment like=

".................peXeuE0ytJgpQcXeR5aHlfLa8dAt0obasd hello@world"

ssh-keygen ptaduri@c3pusas1
ssh-keygen -R hostname
ssh-keygen -l -f ~/.ssh/known_hosts
2010-12-05 04:03:07
User: atoponce
Functions: ssh ssh-keygen
Tags: ssh
10

Will return the SSH server key information for each host you have in your ~/.ssh/known_hosts file, including key size, key fingerprint, key IP address or domain name, and key type.

ssh-keygen -f ~/.ssh/id_rsa -p
2010-07-19 12:53:35
User: darkfader
Functions: ssh ssh-keygen
3

Protects your secret identity with a passphrase.

OSX 10.6 automatically does key forwarding and can store the passphrase in the keychain.

For other OSes, use ssh -A or set ForwardAgent in ssh_config to enable forwarding. Then use ssh-agent/ssh-add.

ssh-keygen -R <the_offending_host>
2010-07-11 19:37:24
User: bunam
Functions: ssh ssh-keygen
Tags: sed
41

In this case it's better do to use the dedicated tool

echo 'Host or User@Host?:'; read newserver && ssh-keygen -N "" -t rsa -f ~/.ssh/id_rsa ; ssh $newserver cat <~/.ssh/id_rsa.pub ">>" ~/.ssh/authorized_keys ; ssh $newserver
2010-05-07 06:24:53
User: alf
Functions: cat echo read ssh ssh-keygen
Tags: ssh ssh-keygen
-2

Some servers don't have ssh-copy-id, this works in those cases.

It will ask for the destination server, this can be IP, hostname, or user@hostname if different from current user.

Ssh keygen will let you know if a pubkey already exists on your system and you can opt to not overwrite it.

ssh-keygen -T moduli-2048 -f /tmp/moduli-2048.candidates
2010-01-29 19:35:21
User: eastwind
Functions: ssh ssh-keygen
1

this command test the moduli file generated by the command ssh-keygen -G /tmp/moduli-2048.candidates -b 2048 . The test can be long depend of your cpu power , around 5 minutes to 30 minutes

ssh-keygen -G /tmp/moduli-2048.candidates -b 2048
2010-01-29 19:33:23
User: eastwind
Functions: ssh ssh-keygen
0

if you lost your moduli file in openssh server side you need generate new one with this command then test if the number generated can be used with ssh-keygen -T moduli-2048 -f /tmp/moduli-2048.candidates

ssh-keygen -l -f /etc/ssh/ssh_host_rsa_key.pub && ssh-keygen -l -f /etc/ssh/ssh_host_dsa_key.pub
2009-10-26 17:52:41
Functions: ssh ssh-keygen
Tags: ssh bash
4

Get your server's fingerprints to give to users to verify when they ssh in. Publickey locations may vary by distro. Fingerprints should be provided out-of-band.

ssh-keygen -R `host hostname | cut -d " " -f 4`
2009-09-23 14:58:28
User: flart
Functions: cut hostname ssh ssh-keygen
5

Quick shortcut if you know the hostname and want to save yourself one step for looking up the IP address separately.

ssh-keygen; ssh-copy-id user@host; ssh user@host
2009-03-18 07:59:33
User: bwoodacre
Functions: ssh ssh-keygen
Tags: openssh
18

This command sequence allows simple setup of (gasp!) password-less SSH logins. Be careful, as if you already have an SSH keypair in your ~/.ssh directory on the local machine, there is a possibility ssh-keygen may overwrite them. ssh-copy-id copies the public key to the remote host and appends it to the remote account's ~/.ssh/authorized_keys file. When trying ssh, if you used no passphrase for your key, the remote shell appears soon after invoking ssh user@host.

ssh-keygen -l -f [pubkey] | awk '{print $2}' | tr -ds ':' '' | egrep -ie "[a-f0-9]{32}"
ssh-keygen -i -f $sshkeysfile >> authorized_keys
ssh-keygen -R \[localhost\]:8022
2009-02-05 11:48:09
User: Sekenre
Functions: ssh ssh-keygen
6

Useful if you have to tunnel ssh through a local port and it complains of the host key being different. Much easier than manually editing the file.