Is there any way to set variables in ssh?

Still working on this, but is there any function / command that I can use to set some simple variables?

Logging into mysql is faster when I'm already in ssh'd, but entering the full connection string is a bit annoying.

Any way to do something like:

mysql $ {variable} dbname

Where variablewill there be something like-u user -p -h hostname

Or is there another way to do what I need?

+3
source share
2 answers

Create an alias in ~/.bash_profile(on the server). Changes in ~/.bash_profilewill have an effect the next time you log in.

For example, add

alias conMy='mysql -u user -p -h hostname' 

And then use it with

ssh yourServer conMy dbname

, :

conMy dbname

bash manpage:

[-p] [ [= ]...]      -p name = value . , , . , . , , . true, , .

+7

ssh. .

0

Source: https://habr.com/ru/post/1705149/


All Articles