TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

SSH Tricks

223 点作者 ahalan超过 13 年前

18 条评论

beagle3超过 13 年前
The most magical command he didn't mention is 'ssh-copy-id'. If you can log-in to a host with password, you just 'ssh-copy-id myuser@thishost', supply the password once, and from that moment you can ssh with public key authentication. Extreme magic.<p>Also, sshfs works great, but has some issues with memory mapped files that silently lose writes. Luckily (?) most programs don't use mmap to write files, so it's not very noticeable.<p>All in all, ssh is one of the greatest tools.
评论 #3012078 未加载
评论 #3014105 未加载
ary超过 13 年前
&#62; /dev/null .known_hosts<p>This is <i>not</i> a good idea (and far from "awesome"). I get why he's doing it, but suggesting that weakening the security of a tool that is meant to <i>enhance</i> it is bad advice.
评论 #3012025 未加载
评论 #3012070 未加载
评论 #3012106 未加载
评论 #3012027 未加载
评论 #3012030 未加载
JoshTriplett超过 13 年前
Another handy trick: put this script on your path somewhere, and name it "ssh-argv0":<p><pre><code> #!/bin/sh exec ssh "${0##*/}" "$@" </code></pre> Then create symlinks to ssh-argv0 for common hostnames you ssh to, shortened using host aliases as suggested in the article. You now have a command for each host, which you can use as a prefix like sudo to run a single command on that host. For instance, "myth sudo reboot".<p>If you're used to using "ssh user@box foo", and not always for the same user (in which case you could use "User" in .ssh/config), you can do the same thing via "box -l user foo"
评论 #3012562 未加载
评论 #3012785 未加载
评论 #3014112 未加载
xtacy超过 13 年前
The ssh escape sequence "~" (without quotes) comes in handy at times.<p><pre><code> "~ C" Gives you a ssh command prompt. Press ? for help. "~ ." Closes the ssh connection; useful for unresponsive ssh connections!</code></pre>
评论 #3012156 未加载
dotBen超过 13 年前
Ok, not techically part of SSH itself but I think SShuttle[1] is one of the most awesome SSH tricks around.<p>[1] <a href="https://github.com/apenwarr/sshuttle" rel="nofollow">https://github.com/apenwarr/sshuttle</a>
评论 #3016528 未加载
评论 #3012662 未加载
jerrya超过 13 年前
I hadn't known about sshfs - that sounds great and I'll have to look it up.<p>One of my favorite features is ssh forced commands, <a href="http://oreilly.com/catalog/sshtdg/chapter/ch08.html#22858" rel="nofollow">http://oreilly.com/catalog/sshtdg/chapter/ch08.html#22858</a> which I use on infrequently used remote servers to present menus of pre-defined commands to me or to others. And at other times, I can use it to kick off a daemon on a remote server just by ssh'ing to that remote server with the proper key.<p>It's a simple way to create a "compile server" and then use one command line from my preferred machine to tell the compile server to check a certain directory and compile everything within it.<p>Yeah, ssh is nice.
darrikmazey超过 13 年前
Another trick I especially like is to use the command="" syntax inside of an authorized_keys file to allow a user to execute certain commands via ssh, especially handy for git-shell.
jpdoctor超过 13 年前
Anyone know how to ensure 8 bits worth of keyboard are passed? (Run emacs over ssh and you sometimes get stuck without the meta key working.)
jvogt超过 13 年前
I have a lot of machines I regularly connect to. Parsing the known_hosts file and adding to my shell's tab completion was a nice timesaver. Here's the line from my .bash_profile<p>complete -W "$(echo `cat ~/.ssh/known_hosts | cut -f 1 -d ' ' | sed -e s/,.*//g | uniq | grep -v "\["`;)" ssh
sneak超过 13 年前
I'm not sure how this could omit "ssh -D".<p>Also, is it just me, or might his ssh-reagent bash function add keys to some other user's ssh agent process if they've sufficiently modified the permissions on their socket file in the temporary directory to allow you to write to it?
there超过 13 年前
many shells can be setup to autocomplete a list of hosts parsed from ~/.ssh/known_hosts.<p>for tcsh, see <a href="http://www.opensource.apple.com/source/tcsh/tcsh-63.1/tcsh/complete.tcsh" rel="nofollow">http://www.opensource.apple.com/source/tcsh/tcsh-63.1/tcsh/c...</a>
评论 #3014182 未加载
Spoutingshite超过 13 年前
I use SuperPutty on my Windows PC to manage many putty sessions at a time...it is a little clunky, however it is better than having putty open 5 or 10 times.
0x12超过 13 年前
my personal favorite, a one liner to set up an email tunnel on a non-privileged port:<p>ssh -f username@mymailserver.com -L 2000:mymailserver.com:25 -N
评论 #3013189 未加载
koenigdavidmj超过 13 年前
<a href="http://www.funtoo.org/wiki/Keychain" rel="nofollow">http://www.funtoo.org/wiki/Keychain</a> is also quite nice.
RyanMcGreal超过 13 年前
+1 for sshfs, which comes in handy for backing up my hard drive to an external machine.
primo44超过 13 年前
In case the article's author stops by:<p>- loose rhymes with "goose". The word is "lose".
zobzu超过 13 年前
gpg-agent. ;-)
gnu6超过 13 年前
Nice use of /tmp, I hope you're the only one on your machine.
评论 #3013613 未加载