Linux and SSH
 

Subscribe now and choose from over 30 free gifts worth up to £49 - Plus get £25 to spend in our shop

[Closed] Linux and SSH

24 Posts
13 Users
0 Reactions
61 Views
Posts: 77688
Free Member
Topic starter
 

Any advice here please?

I've taken a copy of a production Ubuntu server VM and spun it up in our Lab to turn into a development server. I've changed the IP addressing and hostname, and touched nothing else.

I can now SSH to it, but the session disconnects me after a few seconds - or rather, the session just freezes, then PuTTY terminates a little while later.

What am I missing here? Is there something froody I need to do with SSH if I rename a machine?


 
Posted : 27/01/2017 11:50 am
Posts: 91096
Free Member
 

Yeah, you'll have to er.. change the entry in.. then add.. er.. umm.. I dunno, sorry.


 
Posted : 27/01/2017 12:01 pm
Posts: 77688
Free Member
Topic starter
 

That's pretty much where I'm at.


 
Posted : 27/01/2017 12:10 pm
Posts: 0
Free Member
 

[img] [/img]

but i can't offer any help...


 
Posted : 27/01/2017 12:12 pm
Posts: 0
Free Member
 

I would re-install the SSH server. It could be that the change in hostname is upsetting the crypto.

Something like:

sudo apt-get remove --purge openssh-server && sudo apt-get install openssh-server


 
Posted : 27/01/2017 12:13 pm
Posts: 3456
Full Member
 

Are you using Putty or Kitty? (I know you said Putty, but you might be using a general term)

I use lots of servers every day, Kitty connects fine to most of them, but one doesn't like it and only allows Putty... I haven't worked out why.


 
Posted : 27/01/2017 12:19 pm
Posts: 77688
Free Member
Topic starter
 

Hmm.

I've just done a round of updates (via the console) on it and, perhaps coincidentally, now that I've gone back to SSH it seems to have stopped doing it. Bizarre.

If it reoccurs I'll reinstall the SSH server as suggested. Cheers.


 
Posted : 27/01/2017 12:19 pm
Posts: 811
Free Member
 

Are you sure the IP details have been set OK - no clashes etc?
Is the hostname the same as any other machine on the available network?
If you look in the log can you see the ssh server starting and stopping?
If you use other network ops like ftp, (x)rdp, do these hold up ok?
Can you ssh from the VM to your client Ok?

Edit: Fixed automagically - the best type of fixes. 🙂


 
Posted : 27/01/2017 12:20 pm
Posts: 3456
Full Member
 

Also, where have you changed the hostname?

/etc/hosts/
/etc/sysconfig/network

I'm using RedHat/CentOS, so may be different in Ubuntu, but I've never known needing to reinstall openssh after a hostname change.


 
Posted : 27/01/2017 12:21 pm
Posts: 77688
Free Member
Topic starter
 

Are you using Putty or Kitty? (I know you said Putty, but you might be using a general term)

Kitty's the one that gives you clickable URLs, isn't it? But no, I'm using PuTTY and not a.n.other terminal emulator.


 
Posted : 27/01/2017 12:22 pm
Posts: 77688
Free Member
Topic starter
 

Are you sure the IP details have been set OK - no clashes etc?

Reasonably so.

Is the hostname the same as any other machine on the available network?

Nope.

If you look in the log can you see the ssh server starting and stopping?

I looked in, er, /var/log/auth I think, nothing leaps out at me.

If you use other network ops like ftp, (x)rdp, do these hold up ok?
Can you ssh from the VM to your client Ok?

Didn't try either of those. Being a clone of a production server there's not a lot of extra services running.

Also, where have you changed the hostname?

IP addressing in /etc/network/interfaces
Hostname in /etc/hostname and /etc/hosts

I don't have a sysconfig, that must be a RH thing.


 
Posted : 27/01/2017 12:27 pm
Posts: 621
Free Member
 

somouk - Member
I would re-install the SSH server. It could be that the change in hostname is upsetting the crypto.

Something like:

sudo apt-get remove --purge openssh-server && sudo apt-get install openssh-server

Good thinking, but I would have thought it would fail to connect in that case..?

I hate it when things fix themselves. You never know if it's really sorted, or whether it's going to raise its ugly head at 2am on Sunday night a few weeks from now.

There is something strange with Ubuntu's SSH setup though. If you edit a config file, e.g. to change permit root logins to YES then just restarting or even stopping and starting the SSH/SSHd services isn't enough. You need to actually reboot the box to get it to pick up the change... Most strange


 
Posted : 27/01/2017 12:28 pm
Posts: 77688
Free Member
Topic starter
 

I think I'm going to write this off as sunspots. Thanks all who replied.

I hate it when things fix themselves. You never know if it's really sorted, or whether it's going to raise its ugly head at 2am on Sunday night a few weeks from now.

"Have you fixed that intermittent fault?"

Umm... so far...


 
Posted : 27/01/2017 12:28 pm
Posts: 3456
Full Member
 

Kitty is Putty with added bells and whistles. Personal favourites are;

- Drag and drop SCP
- CTRL+Shift+left-click to open duplicate session
- Shift+F3 to open WinSCP connection to server

It does more too, but those are the bits that I find "invaluable".


 
Posted : 27/01/2017 12:28 pm
Posts: 621
Free Member
 

Hostname in /etc/hostname and /etc/hosts

What does hostname -f return (and does it return swiftly?)


 
Posted : 27/01/2017 12:29 pm
Posts: 77688
Free Member
Topic starter
 

Yeah, I've used it previously but a long time ago. The author of PuTTY is a friend of mine, so straying away from it seems... dirty.


 
Posted : 27/01/2017 12:30 pm
Posts: 77688
Free Member
Topic starter
 

What does hostname -f return (and does it return swiftly?)

The correct FQDN, and yes. (I'm connecting via IP address rather than hostname.)


 
Posted : 27/01/2017 12:31 pm
Posts: 3456
Full Member
 

straying away from it seems... dirty

It's def not as solid as Putty, but the added trinkets have lured me away.


 
Posted : 27/01/2017 12:33 pm
 pdw
Posts: 2206
Free Member
 

If it's connecting successfully then freezing, it's not an issue with the hostname.

The most likely explanation for this is a duplicate IP address (you haven't managed to spin up two copies of the VM have you?). Other possibilities are an MTU issue (if it freezes the first time you run a command that produces a lot of output, unlikely on a local network) or a NAT router timing-out your session, unlikely to happen after just a few seconds.


 
Posted : 27/01/2017 12:56 pm
Posts: 0
Free Member
 

Any intrusion detection systems on the network?

Rachel


 
Posted : 27/01/2017 1:01 pm
Posts: 77688
Free Member
Topic starter
 

IP was my first thought. If it is a duplicate IP, then it's something not responding to ICMP (and there's nothing like that in the Lab that I'm aware of). Plus, I could still ping out from a console session when it did it.

Network issues seem unlikely, if only because nothing else is doing it.

Any intrusion detection systems on the network?

Nothing like that. The Lab network is frankly a sprawling mess that has grown organically as a succession of engineers have buggered about with it over the years before it came under my jurisdiction, but one thing it's not is sophisticated. There's no budget attached so it's all built out of Wombled cast-offs.


 
Posted : 27/01/2017 1:03 pm
Posts: 13594
Free Member
 

- CTRL+Shift+left-click to open duplicate session

right click on top of window, select "Duplicate" session with Putty


 
Posted : 27/01/2017 4:57 pm
Posts: 4954
Free Member
 

Is it on the same sub net? Ping, check your ARP table, try disabling the NIC on the server or in plug or something, clear the ARP ping the server again see if a different Mac address terms up.


 
Posted : 27/01/2017 6:29 pm
Posts: 0
Free Member
 

[quote=Cougar ]The author of PuTTY is a friend of mine

name dropper

I'm sure I've had a similar issue which I solved, but can't remember at all what the problem was - that's not really very helpful is it! ISTR it was something to do with IP and routing though (maybe worth checking the remote client doesn't have a conflict either, and check subnetting).


 
Posted : 27/01/2017 8:01 pm
Posts: 0
Free Member
 

Checked the syslog / authlog for any entries which explain the session termination ?


 
Posted : 27/01/2017 8:10 pm