From 197f834ee2de9b46ede7b2026529d2f462fadb5b Mon Sep 17 00:00:00 2001 From: Ian Gulliver Date: Mon, 15 Apr 2019 01:25:50 +0000 Subject: [PATCH] SSH agent forwarding & screen --- 2016-02-28-ssh-agent-forwarding-screen.html | 21 +++++++++++++++++++ index.html | 1 + .../2016-02-28-ssh-agent-forwarding-screen.md | 20 ++++++++++++++++++ markdown/index.md | 1 + 4 files changed, 43 insertions(+) create mode 100644 2016-02-28-ssh-agent-forwarding-screen.html create mode 100644 markdown/2016-02-28-ssh-agent-forwarding-screen.md diff --git a/2016-02-28-ssh-agent-forwarding-screen.html b/2016-02-28-ssh-agent-forwarding-screen.html new file mode 100644 index 0000000..a1f3dfa --- /dev/null +++ b/2016-02-28-ssh-agent-forwarding-screen.html @@ -0,0 +1,21 @@ + + + + + +

ssh-agent forwarding and screen not playing nicely is one of those things that I’ve dealt with so long that it just became routine. Resume a screen from a previous connection? Outgoing SSH won’t work, and that’s just the way it is. One day this week, I finally decided to see if I can fix it, and fortunately the Internet provides. That doc has a bunch of complexity about X forwarding, which I haven’t cared about in years, so here’s the distilled version. You’ll need to have already set up agent forwarding. On the host with your screen session:

+ +
tee ~/.ssh/rc <<'END'
+if test "$SSH_AUTH_SOCK"; then
+  ln -sf $SSH_AUTH_SOCK ~/.ssh/ssh_auth_sock
+fi
+END
+
+tee -a ~/.screenrc <<END
+setenv SSH_AUTH_SOCK $HOME/.ssh/ssh_auth_sock
+END
+
+ +

Reconnect, restart screen once, never worry about it again. Changing my life.

+ + diff --git a/index.html b/index.html index 8a24580..b9588e8 100644 --- a/index.html +++ b/index.html @@ -14,6 +14,7 @@
  • 2016-Mar-13: Raspbian setup notes
  • 2016-Mar-02: More poll()/epoll fun
  • 2016-Mar-01: Asynchronous name resolution in C
  • +
  • 2016-Feb-28: SSH agent forwarding & screen
  • diff --git a/markdown/2016-02-28-ssh-agent-forwarding-screen.md b/markdown/2016-02-28-ssh-agent-forwarding-screen.md new file mode 100644 index 0000000..d32796c --- /dev/null +++ b/markdown/2016-02-28-ssh-agent-forwarding-screen.md @@ -0,0 +1,20 @@ + + + + + +ssh-agent forwarding and screen not playing nicely is one of those things that I’ve dealt with so long that it just became routine. Resume a screen from a previous connection? Outgoing SSH won’t work, and that’s just the way it is. One day this week, I finally decided to see if I can fix it, and fortunately the Internet [provides](https://gist.github.com/martijnvermaat/8070533). That doc has a bunch of complexity about X forwarding, which I haven’t cared about in years, so here’s the distilled version. You’ll need to have already [set up agent forwarding](https://developer.github.com/guides/using-ssh-agent-forwarding/). On the host with your screen session: + + tee ~/.ssh/rc <<'END' + if test "$SSH_AUTH_SOCK"; then + ln -sf $SSH_AUTH_SOCK ~/.ssh/ssh_auth_sock + fi + END + + tee -a ~/.screenrc < diff --git a/markdown/index.md b/markdown/index.md index dec4571..c3632b2 100644 --- a/markdown/index.md +++ b/markdown/index.md @@ -13,5 +13,6 @@ 1. 2016-Mar-13: [Raspbian setup notes](2016-03-13-raspbian-setup-notes.html) 1. 2016-Mar-02: [More poll()/epoll fun](2016-03-02-more_poll_epoll_fun.html) 1. 2016-Mar-01: [Asynchronous name resolution in C](2016-03-01-asynchronous-name-resolution-in-c.html) +1. 2016-Feb-28: [SSH agent forwarding & screen](2016-02-28-ssh-agent-forwarding-screen.html)