TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

SSH Kung Fu

487 pointsby staselabout 11 years ago

21 comments

patio11about 11 years ago
A trick I learned recently: create .ssh&#x2F;config<p>File format: as many of the following blocks as you like<p><pre><code> Host $ALIAS &lt;-- whatever you want here Hostname www.example.com User someuser Port 1234 </code></pre> You can now ssh to that server as that user by doing &quot;ssh $ALIAS&quot; on the command line, without needing to specify the port or user with the usual command line arguments, or necessarily spell out the entire host name.
评论 #7658742 未加载
评论 #7659835 未加载
评论 #7658938 未加载
评论 #7659083 未加载
评论 #7662886 未加载
评论 #7658722 未加载
评论 #7668047 未加载
评论 #7660254 未加载
hfabout 11 years ago
A few commenters do not seem to be aware that it is perfectly possible to use passphrase-protected keys for automated tasks (cronjobs and the like).<p>The excellent (though unfortunately named) keychain[0] utility provides a ready and powerful abstraction for <i>both</i> ssh-agent and gpg-agent.<p>[0] <a href="https://github.com/funtoo/keychain" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;funtoo&#x2F;keychain</a>
评论 #7662415 未加载
peteretepabout 11 years ago
From the article:<p><pre><code> &gt; No more password prompts </code></pre> Is that - you ask - because he&#x27;s using ssh-agent? No, it&#x27;s because he doesn&#x27;t tell you you should be using a password-protected key. Some kung fu.
评论 #7658554 未加载
hfabout 11 years ago
The situation with beginner-friendly SSH tutorials is, in a much lesser degree perhaps, comparable to the crypto texts: Good will alone does more harm than good.<p>This treatment ssh does not mention ssh-agent and, more importantly perhaps, implies that there is a certain virtue in having private keys unprotected by sturdy passphrases lying around.<p>There is not; most emphatically not.
评论 #7664017 未加载
edwintorokabout 11 years ago
The article mentions ECDSA, but doesn&#x27;t mention Ed25519, which is supported since OpenSSH 6.5: <a href="https://lwn.net/Articles/583485/" rel="nofollow">https:&#x2F;&#x2F;lwn.net&#x2F;Articles&#x2F;583485&#x2F;</a><p>As a bonus Ed25519 keys unconditionally use bcrypt for protecting the private key
icebrainingabout 11 years ago
This is why reading the man pages is useful; you&#x27;d get all this and more, including:<p><pre><code> - X11 Forwarding - Reverse forwarding (bind listening sockets on the remote machine, redirecting to a local service) - SSH-Based VPNs</code></pre>
ak217about 11 years ago
Best trick I learned in the past few years is SSH control sequences.<p>Disconnected from your host but not timed out yet? Press Enter, ~, . and the client will quit.
评论 #7660342 未加载
terhechteabout 11 years ago
&gt; Sharing Connections<p>I&#x27;ve tried this before, and what effectively always happened (to me) is that as soon as I started copying a file, I couldn&#x27;t continue working in Vim anymore until the file was done transmitting because the copying would eat all the bandwidth. There may be a flag or setting around this, but I&#x27;ve never found it. When I open two connections, it is usually fine.
评论 #7658676 未加载
评论 #7658650 未加载
bryanlarsenabout 11 years ago
Another recommendation: start an SSH server on port 443 on a server somewhere. Then if you&#x27;re stuck somewhere on an untrusted network, one that blocks most outgoing ports or one that throttles non-HTTP ports, you can use SSH for tunneling and&#x2F;or setting up a quick SOCKS proxy to get yourself encrypted, unblocked, full speed internet access.
Morgawrabout 11 years ago
I just learned about remote file editing with vim and scp thanks to this article, it&#x27;s the only thing I didn&#x27;t know about and... wow, it&#x27;s amazing. This will make my life much easier every time I have to remotely edit some config files on my servers.<p>As for the rest of the article, really nice stuff. Nice tricks for ssh newbies. I wish he also talked about setting up a nonce system with ssh or move sshd to a non-default port to prevent attackers spamming port 22, or even remove password authentication altogether.
评论 #7658681 未加载
hfabout 11 years ago
While we are busy dispensing wisdom: Do use<p><pre><code> PermitRootLogin without-password </code></pre> instead of &#x27;yes&#x27; in &#x2F;etc&#x2F;ssh&#x2F;sshd_config if you absolutely must have ssh root access.
评论 #7660446 未加载
评论 #7658950 未加载
评论 #7658923 未加载
评论 #7660259 未加载
luxpirabout 11 years ago
One problem I have with SSH is DPI. Deep Packet Inspection seems to be behind the SSH block in place at a local library I work at. SSH out in any form just isn&#x27;t possible there, even via a browser-based console (such as that used by Digital Ocean, for example). There doesn&#x27;t seem to be a suitable solution to get around it offered anywhere.<p>My own fix was to use 3G to do the SSH work via a tethered phone and to use the wifi adapter to run the bulk of any other web traffic. It&#x27;d be great to have a workaround for DPI, though, if anyone has any experience there.
评论 #7659587 未加载
评论 #7658997 未加载
评论 #7659062 未加载
评论 #7659066 未加载
评论 #7659547 未加载
评论 #7670485 未加载
grnabout 11 years ago
I can recommend Mastering SSH - it&#x27;s a nice, short read.<p><a href="http://www.amazon.com/SSH-Mastery-OpenSSH-PuTTY-Tunnels-ebook/dp/B006ZO9ULK/" rel="nofollow">http:&#x2F;&#x2F;www.amazon.com&#x2F;SSH-Mastery-OpenSSH-PuTTY-Tunnels-eboo...</a>
评论 #7693333 未加载
magnetikonlineabout 11 years ago
Some good tips here - I like Controlmaster&#x2F;Controlpath.<p>Note that on the tip of ~&#x2F;.ssh&#x2F;known_hosts providing ssh auto completion, adding SSH server config to ~&#x2F;.ssh&#x2F;config will also enable auto completion.
评论 #7659943 未加载
ambrop7about 11 years ago
About the &quot;Lightweight Proxy&quot; (ssh -D), if you want it to be transparent to the application (not require SOCKS support), you can use my tun2socks[1] program. This is useful if you can&#x27;t or don&#x27;t want to set up an SSH tunnel (which requires root permissions on the server). The linked page actually explains exactly this use case. It even works on Windows ;)<p>[1] <a href="https://code.google.com/p/badvpn/wiki/tun2socks" rel="nofollow">https:&#x2F;&#x2F;code.google.com&#x2F;p&#x2F;badvpn&#x2F;wiki&#x2F;tun2socks</a>
评论 #7664641 未加载
Piskvorrrabout 11 years ago
Another useful (albeit ugly) hack is accessing a NATed host which doesn&#x27;t even have a port forwarded, via an intermediate SSH host <i>outside</i> the target network: <a href="http://superuser.com/questions/277218/ssh-access-to-office-host-behind-nat-router/277220#277220" rel="nofollow">http:&#x2F;&#x2F;superuser.com&#x2F;questions&#x2F;277218&#x2F;ssh-access-to-office-h...</a><p>(disclaimer: tooting my own horn here, but it is a mighty useful trick)
mrlebowskiabout 11 years ago
I have a setup similar to this:<p><pre><code> laptop - user (userid: me) F - firewall (userid: me) A - machine 1 in colo (userid: colo) B - machine 2 in colo (userid: colo, machine I want to access) C - machine 2 in colo (userid: colo) . . 100s of machines. </code></pre> Trust (ssh password less login) is setup between me@laptop and me@F, and me@laptop and colo@A, and between all colo machine (A,B,C..). So colo@A can ssh colo@B w&#x2F;o password.<p>I am able to log into colo@A via F w&#x2F;o password as I copied the ssh key there manually. (path me@laptop -&gt; colo@F -&gt; colo@A)<p>QUESTION: Is it possible to ssh to other machines (B,C..) via A while assuming full identity of colo@A? (Path would be me@laptop -&gt; colo@F -&gt; colo@A -&gt; colo@B&#x2F;C&#x2F;..) With my current config when I try to ssh to B it knows request is originating from &#x27;laptop&#x27; and still asks me for password.
评论 #7661553 未加载
beagle3about 11 years ago
While the socks proxy does not require any root (local or remote), it is only useful for programs that support it - which are not many.<p>However, apenwarr&#x27;s sshuttle <a href="https://github.com/apenwarr/sshuttle" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;apenwarr&#x2F;sshuttle</a> is a briliant semi-proxy-semi-vpn solution that, in return for local root and remote python (but not remote root), gives you transparent VPN-style forwarding of TCP connections (and DNS requests if you want). It works ridiculously well. Try it, if you haven&#x27;t yet.
MichaelMoser123about 11 years ago
Very interesting article;<p>I have a shell script that helps with setting up trusted keys: trusted keys help if you need to run automated tests, that involve several machines, or simply if you would like to skip typing in a password on each connection.<p><a href="http://mosermichael.github.io/cstuff/all/projects/2011/07/14/ssh-friends.html" rel="nofollow">http:&#x2F;&#x2F;mosermichael.github.io&#x2F;cstuff&#x2F;all&#x2F;projects&#x2F;2011&#x2F;07&#x2F;14...</a>
vinceguidryabout 11 years ago
Is sshfs a serious replacement for nfs? I&#x27;ve got a Buffalo Nas at home that I use Samba for, but Samba is too slow to watch hi-def videos over. NFS seems to be a pain in the neck to get working on that particular device, and I hate using it on a laptop. I guess I should probably just try it, but I can&#x27;t see SSHFS as being any faster than Samba.
评论 #7660129 未加载
评论 #7663500 未加载
radoslawcabout 11 years ago
for me best trick with ssh so far is to use ssh as proxy command: ssh -o ProxyCommand=&quot;ssh -W %h:%p user@ssh_jump_host.somedomain.net -p some_non_22_port&quot; user@some_host_inside.lan -D 1234<p>above creates dynamic tunel (for use as socks proxy) through jumphost to reach http hosts available only to some_host_inside.lan machine