using ssh on CentOS7 for logging on remote machine

Issues related to configuring your network
Post Reply
nitinkumar
Posts: 17
Joined: 2020/04/29 04:07:16

using ssh on CentOS7 for logging on remote machine

Post by nitinkumar » 2020/05/09 06:30:53

I have created two CentOS 7 virtual machines and am trying to remote log in to another CentOS VM using ssh.
After using command, i am asked to give password for logging in to another machine. So far it is Ok. But after connection, i am
not getting shell prompt of another machine and i get prompt of my current session. but when I type "exit" i get message as
"connection to remote machine is closed." This means I have established a connection. Then why i am not able to log on to another machine?

What steps i need to take to debug this problem?

User avatar
jlehtone
Posts: 3033
Joined: 2007/12/11 08:17:33
Location: Finland

Re: using ssh on CentOS7 for logging on remote machine

Post by jlehtone » 2020/05/09 09:44:15

nitinkumar wrote:
2020/05/09 06:30:53
not getting shell prompt of another machine and i get prompt of my current session.
How can you tell that?

Do "ip ro" in that prompt, exit, and "ip ro" again. Do you get exactly same output?

nitinkumar
Posts: 17
Joined: 2020/04/29 04:07:16

Re: using ssh on CentOS7 for logging on remote machine

Post by nitinkumar » 2020/05/10 06:18:59

I can say i am not getting connected because i find myself in the same machine from where i give ssh command.

"ip ro" command give exactly same output before and after exit.

One more thing, i get connected to the other machine when I give ssh < Ip address of the other machine> but not when I give FQDN . I have given
name and IP address in /etc/hosts and name in /etc/hostname files. I think I am missing some very simple thing.

User avatar
jlehtone
Posts: 3033
Joined: 2007/12/11 08:17:33
Location: Finland

Re: using ssh on CentOS7 for logging on remote machine

Post by jlehtone » 2020/05/10 10:28:10

nitinkumar wrote:
2020/05/10 06:18:59
i get connected to the other machine when I give ssh < Ip address of the other machine> but not when I give FQDN.
This is important. Problem is not in ssh. Problem is in name resolution.
nitinkumar wrote:
2020/05/10 06:18:59
I have given name and IP address in /etc/hosts and name in /etc/hostname files.
Note:
My CentOS 7 system does not have file /etc/hostname at all. Package 'systemd' formally provides it, but file is not there.
man 5 hostname wrote: You may use hostnamectl(1) to change the value of this file during runtime from the command line.
Use systemd-firstboot(1) to initialize it on mounted (but not booted) system images.
When I say "ssh bar", the system looks for a "bar" first from /etc/hosts and then with servers listed in /etc/resolv.conf

Code: Select all

# grep ^hosts /etc/nsswitch.conf 
hosts:      files dns
(My host gets a transient hostname from DHCP server and resolves all names with DNS.)

Does the /etc/hosts in the machine that you try to connect from have line:

Code: Select all

<Ip address of the other machine> FQDN
You can see the IP address that a name resolves to by running:

Code: Select all

ping -c 1 name

nitinkumar
Posts: 17
Joined: 2020/04/29 04:07:16

Re: using ssh on CentOS7 for logging on remote machine

Post by nitinkumar » 2020/05/11 03:53:29

Thanks for your help. I could resolve the issue.

Post Reply

Return to “CentOS 7 - Networking Support”