Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Is there any way to specify, in .ssh/config, a command like:

ssh -t remote-host "screen -dR screen_name"

so I can easily access the remote screen session with ssh remote-host?

Right now I solved this problem using a custom script:

$ cat ~/bin/sssh 

/usr/bin/ssh -t $1 "screen -dR ab"

~/bin stays first at $PATH, but it is unflexible and ugly.

Also I would like to find way to implement host autocompletion for my custom script.

share|improve this question
I would replace $1 with $@. Then you can add more options, not just the hostname. For completion, try executing . /usr/share/bash-completion/completions/ssh , followed by complete -F _ssh sssh – Alex Stragies Jul 7 at 17:59

I'd argue that this is the most flexible way. A script allows you to set up parameters, add conditionals, change the command as needed, all based on the inputs.

There are ways to "force" the command in authorized_keys. But I don't know of a way to force tty allocation except from the command-line or to force a command on the remote server from the local side config files.

Myself, I have a script that scans the config file, checks against DNS with various domains and sets the terminal emulator's title string. I call it from screen on my local system (Ctrl-a g).

share|improve this answer

Use the force, Luke!

Use RequestTTY force in your ~/.ssh/config for the desired host.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.