Monday·15·February·2021
Starting a GNU Screen session via SSH’s ~/.ssh/config //at 05:50 //by abe
This is more or less a followup to this blog posting of mine about AutoSSH and GNU Screen from nearly ten years ago — which by the way is still valid and still the way, I use SSH and GNU Screen.
Recently a friend asked me how to automatically start or reconnect to a GNU Screen session directly via OpenSSH’s configuration file. Here’s how to do it:
Add an entry to ~/.ssh/config
similar to this one:
Host screen_on_server Hostname server.example.org RequestTTY yes RemoteCommand screen -RD
and then just call ssh screen_on_server
and you’ll get
connected to an existing screen session if present, otherwise you’ll a
new new one.
Should work with tmux, too, but might need commandline different
options.
Tagged as: CLI, GNU, OpenSSH, Screen, SSH, ssh_config, tip
// show without comments // write a comment
Related stories
Tuesday·20·March·2012
Happy Birthday GNU Screen! //at 23:46 //by abe
According to this Usenet posting, GNU Screen became 25 years old today. (Found via Fefe.)
And no, it’s not dead. In contrary, the reaction on the mailing list to bug fixes with patches is usually impressingly prompt. :-)
I took this occassion and uploaded a current git snapshot of GNU Screen to Debian Experimental.
Bug #644788 (screen 4.1.0 can’t attach to a running or detached screen 4.0.3 session) is still an issue with that snapshot, but gladly upstream seems to work on a solution for it. There’s even talk about a 4.1.0 beta release soon — although that hasn’t happened yet.
Have fun!
Tagged as: anniversary, birthday, Debian, Experimental, Git, GNU, GNU Screen, screen, snapshot, upload
// show without comments // write a comment
Related stories
Monday·20·February·2012
Git Snapshot of GNU Screen in Debian Experimental //at 01:09 //by abe
I just uploaded a snapshot of GNU Screen to Debian Experimental. The package (4.1.0~20110819git450e8f3-1) is based on upstream’s HEAD whose most recent commit currently dates to the 19th of August 2011.
While the upload fixes tons of bugs which accumulated over the past two years in Debian’s, Ubuntu’s and upstream’s bug tracker, I don’t yet regard it as suitable for the next stable release (and hence for Debian Unstable) since there’s one not so nice issue about it:
- #644788: screen 4.1.0 can’t attach to a running/detached screen 4.0.3 session
Nevertheless it fixes a lot of open issues (of which the oldest is a wishlist bug report dating back to 1998 :-) and I didn’t want to withhold it from the rest of the Debian community so I uploaded it to Debian Experimental.
Issues closed in Debian Experimental
- #25096: digraph table should be run-time configurable
- #152961: lacks tsl/fsl/dsl caps
- #176626: mini-curses type of interface for screen -r w/ multiple screens? (Fixed by suggesting iselect, screenie or byobu)
- #223320: does not switch mouse mode
- #344759: mishandles xterm control string to set window title
- #353090: please enable the built-in telnet
- #361274: cannot reattach to sessionname if there is another session with similar sessionname
- #450421: please raise MAXWIN to at least 100 (merged with #499273)
- #461107: Requires test -t 0 even when opening a new window on existing screen
- #481411: window created with ‘-d -m’ silently ignores ‘-X exec’
- #488619: Session name string escape
- #496750: screen -d -m and -D -m segfault if setenv given with no value in a configuration file
- #532240: screen with caption SEGVs when resized to 1 line tall
- #541793: “C-a h” (mis)documented twice
- #558724: breaks altscreen
- #560231: Please remove restriction on user/login name length
- #578729: outputs spaces when refreshing/attaching a window with “defbce on”
- #591624: segfault when running “screen -d -m” with “layout save default” in .screenrc
- #603009: Updating the screen Uploaders list
- #612990: /etc/init.d/screen-cleanup: should check for existence of screen binary
- #621704: Fix slow scrolling in vertical splits
- #630535: manpage typo
- #641867: version bump (this bug report sparked the upload :-)
Update: Issues also closed in Debian Experimental, but not (yet) mentioned in the Debian changelog
- #238535: screen lock can no more be bypassed by reattaching.
- #446082: Shows cursor in front of the selected window in “windowlist -b”.
- #522689: Passes signals to programs running inside screen on kfreebsd.
- #526002: Adds focus left/right commands.
- #611453: Documents vertical split in man-page.
- #621804 and #630976: Allows longer $TERM than 20 characters
Issues which will be closed in Ubuntu
- #183849: update to git version of screen
- #315237: crashes with certain options and terminal sizes
- #582153: doesn’t accept login names longer than 20 chars
- #588846: slow when using vertical split
- #702094: Copying and pasting from mutt includes many trailing spaces
- #786292: segfaults if using layout saving with “-D -m”
- #788670: segfault in screen/byobu in natty
Please test the version from Experimental
If you are affected by one of the issues mentioned above, please try the version from Debian Experimental and check if they’re resolved for you, too.
Thanks to all who contributed!
A lot of the fixes have been made or applied upstream by Sadrul Habib Chowdhury who also industriously tagged Debian bug reports as “fixed-upstream”. Thanks!
Thanks also to Brian P Kroth who gave the initial spark to this upload by packaging Fedora 15’s git snapshot for Debian and filing bug although the upload is based on the current HEAD version of GNU Screen as this fixes some more important issues than the snapshot Fedora 15 includes. That way also two patches from Fedora/RedHat’s screen package are included in this upload.
(Co-) Maintainer wanted!
Oh, and if you care about the state of GNU Screen in Debian, I’d really appreciate if you’d join in and contribute to our collab-maint git repository – there are still a lot of issues unresolved and I know that I won’t be able to fix all of them myself. And since Hessophanes unfortunately currently has not enough time for the package, we definitely need more people maintaining this package.
P.S.
Yes, I know about tmux and tried to get some of my setups
working with it, too. But I still prefer screen over tmux.
:-)
Tagged as: byobu, Debian, Experimental, git, GNU, GNU Screen, iselect, screen, screenie, snapshot, tmux, Ubuntu, upload
// show without comments // write a comment
Related stories
Friday·10·June·2011
How to find broken symlinks //at 20:31 //by abe
Looking through the man page of find
there is no obvious
way to find broken symbolic links. But there is a simple way involving
only find:
$ find -L . -type l $ find -L . -type l -ls
The option -L
(before the path!) causes find
to follow symbolic links and the expression -type l
causes find to report only symbolic links. But as it follows symlinks,
it only reports those it can’t follow, i.e. broken ones.
The second line also shows where the broken links point to.
To easily show that this really works, just use the color indicator of
GNU ls instead of find
’s builtin -ls
:
$ find -L . -type l -exec ls -lF --color=yes '{}' +
Et voilà, all displayed links show up in red which means they’re broken.
Kudos to CodeSnippets for showing me the right
idea. And thanks to ft of zsh and grml fame for the hint about
find -exec command {} +
instead of find -exec
command {} ;
.
Hint from mika of grml fame: With zsh it is even less code to type:
% ls **/*(-@) % ls -lF **/*(-@)
Thanks, mika!
Tagged as: CLI, coreutils, find, GNU, HTH, ls, POSIX, shell
// show without comments // write a comment
Related stories
Wednesday·24·November·2010
Perfect Team: autossh and GNU Screen //at 01:06 //by abe
SSH is definitely one of my most often used tools, not only for system administration at work but also on the road with my netbook, an EeePC 701 running Debian Sid.
On the road, it often happens that I have a flaky WLAN or UMTS
connection, so I often have to kill (via <Enter>~.
)
and reconnect my SSH session due to a changed IP address or so.
First step against problems arising from using SSH over unreliable network connections is of course GNU Screen. Second step is use SSH keys and ssh-agent to not needing to type the password on every reconnect.
But it’s still very annoying to kill the SSH connection and call ssh again manually. For luck there is autossh, a wrapper around SSH which regularily checks via two tunnels connect to each other on the remote side if the connection is still alive, and if not, it kills the ssh and starts a new one with the same parameters (i.e. tunnels, port forwardings, commands to call, etc.).
It’s quite obvious that this is perfect to be combined with screen’s
-R
and -d
options (Reattach if a detached
screen is around, else start a new screen; detach a currently attached
screen), so I found myself very often typing (or fetching it from the
commandline history :-):
autossh -t sym.noone.org 'screen -Rd'
-t
is necessary to allocate a terminal device on the
remote machine which is not done by default if you directly call a
command via ssh
.
In comparision to OpenSSH, autossh needs the single quotes, because
otherwise it would parse -Rd
as options to parse to
ssh
and bail out. That’s not a real problem, but when
you’re used to just type ssh -t sym.noone.org screen -Rd
without any quotes, you’ll run into this then and when.
Update, 25-May-2010, 14:55: As Carsten Hey points
out, autossh
also supports the --
option to
declare that all following options and parameters must be passed to
ssh
itself. (End of Update)
Typing that often and mistyping it then and when cries for an shell alias or an shell function. So I came up with the following shell function:
asc() { autossh -x -a -t "$@" 'screen -RdU' }
I used a function instead of an alias in case of autossh
will in future regard all parameters given after the command as part
of the command as ssh
does.
The additional options -x
and -a
disable X
and SSH Agent forwarding which both don’t work if you reattach to an
already running screen
.
And if you’re using Zsh as I do, you can even add some more format string magic to set the window title more or less to the expanded alias, eh, function:
function asc() { # Set the title to something more obvious, e.g. the expanded # alias, eh, function print -Pn "\e]0;%n@%m: autossh -t $* 'screen -RdU'\a"; autossh -x -a -t "$@" 'screen -RdU' } compdef asc=ssh
Update, 25-May-2010, 14:59: As Hauke points out in a
comment, Zsh users should also declare that asc
should
have the same tab completion as ssh
itself. The example
above has been updated accordingly. (End of Update)
In the meantime on the EeePC I use asc
on the
commandline more often than ssh
itself. And I nearly no
more type autossh
. (The most common exception here is
autossh hostname tail -F /path/to/some/logfile
.)
Using that function you can also add common ssh
options
for tunneling, etc. — I use it most often like this:
asc -D 1080 sym.noone.org
This opens a SOCKS proxy on localhost, port 1080 and that way I can surf via the host I’m connecting to by SSH.
There’s one small drawback though: You didn’t expect that I can just
invent some new three letter command without a namespace clash, did
you? There is a free game called Advanced Strategic Command whose binary (and Debian package)
is named asc
, too. If you have that game installed, you
can always call it using its full path, e.g.
/usr/games/asc
on Debian.
P.S.: My whole grml based .zshrc is also
available via git at
git.noone.org as well as on github.
Tagged as: alias, asc, autossh, CLI, Debian, EeePC, function, GNU, grml, nuggets, OpenSSH, Proxy, roadwarrior, screen, shell, Sid, SOCKS, SSH, tip, tunneling, zsh, zshrc
// show without comments // write a comment
Related stories
Thursday·26·April·2007
The Software Museum inside the Software Museum //at 13:40 //by abe
Most Linuxers know that Debian and most of its users prefer stable software over up-to-date software. So do I, but sometimes this goes a little bit too far, e.g. when I find software which has been compiled years before the first line of Linux kernel code has been written:
C:\>ls +version GNU ls, Version 1.4.0.2 (compiled Sep 19 1990 12:43:10 for MS-DOS) C:\>ls -alF gnu\ total 521 drwxrwxrwx 1 anonymou anonymou 4096 Mar 26 23:16 ./ drwxrwxrwx 1 anonymou anonymou 4096 Mar 26 23:17 ../ -rwxrwxrwx 1 anonymou anonymou 17868 Sep 19 1990 cat.exe* -rwxrwxrwx 1 anonymou anonymou 20028 Sep 19 1990 cmp.exe* -rwxrwxrwx 1 anonymou anonymou 26780 Sep 19 1990 cp.exe* -rwxrwxrwx 1 anonymou anonymou 17948 Sep 19 1990 cut.exe* -rwxrwxrwx 1 anonymou anonymou 27138 Sep 24 1990 grep.exe* -rwxrwxrwx 1 anonymou anonymou 16572 Sep 19 1990 head.exe* -rwxrwxrwx 1 anonymou anonymou 27756 Sep 19 1990 ls.exe* -rwxrwxrwx 1 anonymou anonymou 23100 Sep 19 1990 mv.exe* -rwxrwxrwx 1 anonymou anonymou 19820 Sep 23 1990 rm.exe* -rwxrwxrwx 1 anonymou anonymou 37644 Sep 19 1990 tac.exe* -rwxrwxrwx 1 anonymou anonymou 20188 Sep 19 1990 tail.exe* C:\>
And yes, this looks like DOS. This is FreeDOS (1:0.0.b9r5a-3) inside of dosemu, packaged for Debian 4.0 Etch and installed from the original Debian archives.
BTW, the date looks quite authentic: According to the ChangeLog, Version 1.4 of the GNU Fileutils have been released on the 9th of September 1990. The oldest version of the GNU Fileutils (nowadays coreutils) available on the GNU FTP server is version 3.13 from July 1996, though.
I really wonder how many buffer overflows this version has. And I
wonder if there’s really a scenario in which this combination (Debian
→ dosemu → FreeDOS → GNU fileutils) could be exploited.
Tagged as: Debian, dosemu, Etch, FreeDOS, GNU, GNU Coreutils, GNU Fileutils, Linux, ls, Made my day, MS-DOS, Security, Vintage
// show without comments // write a comment