“Everything is a file” rocks
Classified in : Homepage, Debian, Command line, Miscellaneous
Unix rocks, or at least one of its design feature does: everything is a file.
Here is one funny use of that feature. I consider that programs that manipulate text should basically take it on their standard input, and write it to their standard output, while specifying the name of an input or output file should be an optional refinement.
Well, at least one program was designed the other way: when used to import a foreign key, ssh-keygen -i has no option to read it on its standard input. No problem, this can be worked around:
# ssh-keygen -if /dev/stdin [paste the foreign key here]
Unfortunately, that does not work with every action of ssh-keygen since not all of them were written to be able to handle streams, which cannot be rewound.
Opportunistic SSH agent
Classified in : Homepage, Debian, Command line, Lazyweb
To use an SSH agent, one usually has to:
- launch the agent;
- add his key to it.
The first step can be automated in the desktop or shell startup script (this is a typical use case for login shell-only startup scripts, by the way), but the second one cannot if your private key is protected by a passphrase.
OpenSSH tip: connection sharing
Classified in : Homepage, Debian, Command line, To remember
The last versions of OpenSSH brought an interesting feature: sharing multiple sessions over a single connection. When enabled, this is how it works:
- The first time you open an SSH connection to a server (including anything that works on top of SSH, like SCP, SFTP, rsync or Git), it opens a network connection as usual. It also opens a local Unix socket and listens to it for later use.
- The next times you open an SSH connection to that server while the first one is still open, instead of opening a new network connection, it connects to that local Unix socket and lets the first SSH client carry its new session.
Return codes
Classified in : Homepage, Debian, Command line, Grumble
According to Eric S. Raymond, one rule for Unix programming is the Rule of Silence: When a program has nothing surprising to say, it should say nothing. Since return codes are a form of information, I would like to add: when a program has carried out its task with no surprise, it should exit(0).
Viewers should stay in foreground
Classified in : Homepage, Debian, Command line, Grumble
Traditionally, when you start a program to view a document, for instance
xpdf resume.pdf
, it stays in foreground, and only returns when it
finishes, when you are done with the document. Of course you can still run it in
background if you want.
Nowadays, several programs behave in a different way, for instance Evince. When you first start it, it stays in foreground as usual. However, if you launch it a second time while the first instance it still running, it will reuse this existing instance, asking it to open your document in a new window, and immediately return. Other examples are Firefox and LibreOffice.