2

I have installed CentOS7 in VMWare Workstation 12 player and I'm trying to use key-based SSH authentication. I have completed the process of passwordless SSH and it works fine but I have to start the SSHD service every time I open VMWare as it refuses to connect to port 22, which is the default and I haven't changed it.

The hostname is osboxes and the FQDN is osboxes.local.com. For some reason I also need to set hostname as osboxes.local.com all the time manually even if there is entry in /etc/hosts file.

Please suggest how to keep SSHD service running all the time and set permanent FQDN hostname in CentOS7?

0

2 Answers 2

1

In CentOS 7, to start a daemon on boot, one must run the command:

sudo systemctl enable daemon.service

In your case, you must run:

sudo systemctl enable sshd.service

For Fully Qualified Domain Name, you should add the following line to /etc/hosts in your host (not virtual machine) according to the ip address of the virtual machine:

192.168.*.* osboxes osboxes.local.com

After that, you can login just with:

ssh user@osboxes

Also, if one ever wishes to stop a daemon starting on the boot:

sudo systemctl disable daemon.service

is the command to run. And,

sudo systemctl start daemon.service
sudo systemctl stop daemon.service
sudo systemctl status daemon.service

are the commands to start, stop and view status of a service.

Last but not least,

sudo systemctl list-unit-files

shows what services are set to enabled/disabled on boot.

0
1

If you want to set the hostname, put osboxes.local.com in /etc/hostname. That will set the default hostname when the system boots. (This is different from previous versions of CentOS, which defined the hostname in /etc/sysconfig/network.)

1
  • Thanks for reply. I edited /etc/hostname to make entry osboxes.local.com but manually I used to set FQDN by command "hostname osboxes.local.com". When i made entry in /etc/sysconfig/network it worked for me. Now after command "hostname" I get "osboxes.local.com" i.e. FQDN
    – Shitalb1
    Commented Sep 21, 2016 at 14:32

You must log in to answer this question.

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