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.

sshrc – make your ssh sessions feel like home

235 pointsby Russell91over 10 years ago

21 comments

DrewRWxover 10 years ago
Ouch, this is a better version of what I submitted a few days ago [1]. I guess that&#x27;s what I get for trying to emulate the unwieldiness of ssh_config.<p>[1] <a href="https://news.ycombinator.com/item?id=8324538" rel="nofollow">https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=8324538</a>
评论 #8343982 未加载
gburtover 10 years ago
I feel like this should be out of the box ssh functionality. This is exactly what I&#x27;ve needed my whole sshing career.
c3RlcGhlbnI_over 10 years ago
I made myself a simpler version of this a while back. I would simply put the rcfile in a folder and then host that folder with:<p><pre><code> python2 -m SimpleHTTPServer 12345 </code></pre> Then you can just use something like the following function to get a remote session:<p><pre><code> sshrc() { ssh -R 12345:127.0.0.1:12345 -t ${*:1} &#x27;bash -c &quot;bash --rcfile &lt;(curl -s http:&#x2F;&#x2F;127.0.0.1:12345&#x2F;sshrc)&quot;&#x27; } </code></pre> This has some nice side effects in that you can then just host your vimrc the same way. I think you can get vim to load plugins from a http runtime path too, but I have never looked into it.<p>Doing it this way has its own quirks though.
derekp7over 10 years ago
Something similar, which allows you want to extend shell scripts to a remote system transparently is &quot;rpcsh&quot; -- take a look at: <a href="https://gist.github.com/derekp7/9978986" rel="nofollow">https:&#x2F;&#x2F;gist.github.com&#x2F;derekp7&#x2F;9978986</a><p>This function allows you to push out local functions, variables, and arrays to a remote system. There is an updated version in the client script for my backup utility (snebu), which also includes getting remote variables returned to the local shell script, and also bouncing through sudo.<p>Should I move this to a regular project on Github, or keep it in the gist?
TravisLSover 10 years ago
Well, this post read my mind. Literally my first thought waking up this morning was &quot;why don&#x27;t I have some way to use my .vimrc over ssh?&quot; I open up Hacker News and voila!<p>Very nice - clean and simple.
possibilisticover 10 years ago
I was thinking of putting together a crude hack to implement just a subset of what this offers. I cannot thank the authors enough. I&#x27;m trying this out the moment I get home.<p>I feel as though we should have had first-class support for portable environments all along, and it shocks me that we haven&#x27;t considered building this kind of facility before. This could be a game changer. Like vim package managers and other sensibly modern things, I totally expect to see this evolve to become the new norm.<p>I see this kind of configuration:<p>* global personal configs (lightweight, truly global settings for work and home)<p>* local overrides (work, home, per machine, non-SSH)<p>* remote overrides (SSH machines)<p>Global configs should be portable everywhere. For everything else, I see a system capable of merging several such configs and matching the current environmental and capability context.
donwover 10 years ago
Fantastic. Looks like a perfect complement to my Workspace[1] script, and way easier than having to git push&#x2F;pull my dotfiles directory.<p>Thanks!<p><a href="https://github.com/matadon/workspace" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;matadon&#x2F;workspace</a>
评论 #8344527 未加载
laumarsover 10 years ago
I do something like this manually. I set up an alias on my home that copies a locally stored environments file onto any server I ssh onto.<p>Pretty simple stuff to set up, but allows for some pretty powerful configuration
评论 #8345551 未加载
larryboltover 10 years ago
I wonder if it would be able to make it work with mosh (<a href="http://mosh.mit.edu/" rel="nofollow">http:&#x2F;&#x2F;mosh.mit.edu&#x2F;</a>), which would be awesome!
评论 #8344451 未加载
jphover 10 years ago
Eureka! This so simple to use and so useful -- I&#x27;ll use sshrc every day now. And the embedded xxd -ps is a clever copy. Great idea Russell. Thank you.
jeroenjanssensover 10 years ago
As a complement to this nice tool, I can recommend sshfs [1], which enables you to mount a remote machine as a local folder.<p>[1] <a href="https://www.digitalocean.com/community/tutorials/how-to-use-sshfs-to-mount-remote-file-systems-over-ssh" rel="nofollow">https:&#x2F;&#x2F;www.digitalocean.com&#x2F;community&#x2F;tutorials&#x2F;how-to-use-...</a>
jamiesonbeckerover 10 years ago
Love the elegant simplicity. Should we add something like this to Userify (<a href="https://userify.com" rel="nofollow">https:&#x2F;&#x2F;userify.com</a>) or perhaps offer to pull your dotfiles (.bashrc, .vimrc, etc) from Github?
nhaover 10 years ago
What would it take to adapt this to also source other config files ? I&#x27;m thinking about gitconfig and vimrc, but I&#x27;m sure there could be more.
评论 #8344342 未加载
评论 #8344406 未加载
userbinatorover 10 years ago
&quot;make your ssh sessions feel like 127.0.0.1&quot;
评论 #8344123 未加载
1945over 10 years ago
I wanted this 10 years ago, thank you!
评论 #8343911 未加载
bsg75over 10 years ago
Are there any security implications using this? It sounds very handy if not.
评论 #8345545 未加载
Shorelover 10 years ago
It doesn&#x27;t let me change the prompt colours.
alexbelover 10 years ago
Is it possible to source my dotfiles?<p>Something like this:<p># .sshrc<p>source ~&#x2F;.bashrc<p>source ~&#x2F;.alias
dobrescuover 10 years ago
this is pretty awesome! any hint on how to load the vimrc config by default without the actual :so?
spc476over 10 years ago
How is this any different than .bashrc or .bash_profile?
评论 #8343980 未加载
评论 #8343979 未加载
linguafrancaover 10 years ago
I&#x27;ve seen tool after tool that tries to make SSH&#x27;ing into a remote machine more &quot;comfortable&quot;, but I honestly don&#x27;t do enough remote work over SSH to make it worth the time required to set it up. I probably spend an hour or two over SSH per week, and Ubuntu&#x27;s minimalist shell defaults are perfectly fine for the little work I do.
评论 #8345191 未加载