Monday, May 6, 2024
 Popular · Latest · Hot · Upcoming
87
rated 0 times [  87] [ 0]  / answers: 1 / hits: 51471  / 3 Years ago, thu, august 5, 2021, 5:12:27

There are a few SSH destinations I will frequently be connecting to and I'm wondering if rather than remember the IP address I can create a host alias for them. I'd like to be able to use...



ssh -p xx [email protected]



I've tried establishing this host in /etc/hosts and unless there's a service I needed to restart it had no effect.


More From » ssh

 Answers
2

Sometimes it is more convenient to have configuration files in our home directory. This avoids having to be root to edit files, and also they can be configured in a way that other users have no access to this data. In addition this configuration will be backed up with our home and also will "survive" an OS upgrade.



To do so we can make a ssh configuration file nano ~/.ssh/config where we can put in valuable information for a connection. A simple entry may have the following content:



Host myremote             # any name for the host
HostName 192.168.178.05 # IP, .local, or hostname if defined
User username # your username
Port 22 # port to listen


There are many other options including user and authentication you can give here (see manpage for ssh_config)



We then can simply issue the following to connect to 192.168.178.05 on port 22:



ssh myremote

[#32641] Saturday, August 7, 2021, 3 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
termetalli

Total Points: 326
Total Questions: 127
Total Answers: 110

Location: Sao Tome and Principe
Member since Sat, Sep 12, 2020
4 Years ago
termetalli questions
Sat, Apr 30, 22, 17:54, 2 Years ago
Mon, Dec 6, 21, 05:24, 2 Years ago
Thu, Jun 30, 22, 00:32, 2 Years ago
Mon, Dec 19, 22, 00:15, 1 Year ago
;