For this purpose you need to setup ~/.ssh/config
file:
touch ~/.ssh/config
chmod 600 ~/.ssh/config
The content of the file should look as:
Host my-destination-host
HostName 192.168.31.90
IdentityFile ~/.ssh/id_rsa
User beta
Port 22
Host another-example
HostName 222.222.22.222
User another-user
IdentityFile ~/.ssh/another-path/id_rsa
Port 2233
RemoteForward 6900 127.0.0.1:5900
RemoteForward 3389 192.168.100.115:3389
Compression yes
CompressionLevel 6
# etc.
Once the file is saved, you will be able to ssh to [email protected]
by the command:
ssh my-destination-host
or for the another example - note the Tab completion is applicable for the Host names:
ssh another-exampTab ↹
Respectively most of the commands that use ssh can use the configuration file. For example rsync
:
rsync -avlu --exclude=".git" ~/Documents/Books my-destination-host:~/Documents/Books
References and more examples, where the ~/.ssh/config
file is used: