working on setting up a local development environment. Im pretty new to Linux. I am using Virtualbox for Ubuntu server inside of the Ubuntu Desktop I am running. After setting up port forwarding I am able to connect to it using these commands: ssh -p2222 user@127.0.0.1orssh -p user@localhost.
I like to connect to it using ssh . I understood that I would be able to do that by simply adding this line to my hostfile:127.0.0.1 example.hostname.
The problem is, I dont know where to find this file. Where is the hostfile located on Ubuntu Desktop 14.04?
2 Answers
The file you're looking for is /etc/hosts.
For ssh you can use ~/.ssh/config and configure shorthand access to host like this:
Host example.hostname
HostName 127.0.0.1
User user
Port 2222If you have bash completion then it would be sufficient to type ssh ex<Tab> to auto-complete to ssh example.hostname and by running this command your ssh will try to connect to host specified in HostName (ip or hostname) with user user and port 2222