1

So, I have a silly question. I have a linux server, and I regularly ssh into it with various devices. I have an 'rc' file in my .ssh directory to print some ASCII art text on login just for decoration. It looks good with all my other computers, but I have a ssh client on my phone where it's all jumbled (due to formatting). I'd like to print just a normal login welcome message for my phone client. I'm not very experienced with configuring ssh, so I was wondering if there is a way to specify different commands to run from different ssh logins, perhaps by ECDSA key fingerprint? Not an important problem, just something I'd like to do. If anyone could help, I'd appreciate it

1 Answer 1

1

It would be very helpful if you could elaborate on what that "rc file" is and what information is available to it (assuming it's a shell script).

Terminal emulators set the TERM environment variable in order to describe their capabilities to programs. This variable is also forwarded over SSH. The value of $TERM may be different between your phone and computers, in which case you could use that to differentiate. Many terminal emulators just set it to xterm, though you might be lucky.

If you cannot use $TERM, you can also configure your SSH client to send a value which you have defined in your SSH configuration (or on the command line when connecting). You can do this by adding AcceptEnv MY_CLIENT to your server's sshd configuration, and then adding SendEnv MY_CLIENT="phone" in the configuration for your phone's SSH client. Your script should then be able to see that variable and determine whether you are connecting from your phone.

See also: https://stackoverflow.com/a/4410137/1106272

Finally, you can use a Match block in your sshd config to set settings based on user, group, host etc. Check out man sshd_config for more information on that. I'm not entirely sure if you can do anything useful with that in this regard, but it could be worth taking a look at.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .