SSH - How to include "-t command" in the ~/.ssh/config file

Solution 1:

I think I'd approach this from the other direction - use 'command=' on the public key entry in your ~/.ssh/authorized_keys file on the remote server, to run your "su -" command.

Then just use/reference the private key in your ~/.ssh/config file (IdentityFile option) for every host/alias ("myserver-root") you want to work this way.

The options available in authorized_keys(5) are documented in sshd(8).

Solution 2:

Use the force Luke!

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

btw. this is also discussed here https://unix.stackexchange.com/questions/27713/ssh-config-way-to-spectify-pseudo-tty-allocation-and-command-execution-like-sc/294468#294468


Solution 3:

Why not add a script to a dir in your path (or an alias for it) called rssh like:

#!/bin/bash
ssh $1 -t 'su -'

Then it is just:

rssh myServer

Tags:

Linux

Ssh

Root