The book is about a war between humans and an alien species set in the future. In the book a pilot merges his mind with a ship. So he can fly the ship and leave his body behind.
Possibly Gordon R. Dickson's Forever Man.
from the Amazon link above:
The ancient starship La Chasse Gallerie is found drifting perilously in space. Despite heavy damage from alien Laagi warships, incredibly the ship is still intact and the voice of its pilot, Raoul Penard, comes through loud and clear. But Penard died over one hundred years ago. On Earth, frantic investigation reveals that Penard may be dead but his mind is very much alive - merged with the ship itself. The staggering potential of this evolutionary breakthrough compels the scientists to embark on a technological journey of astonishing discovery.
Larry Niven wrote "A TearDrop Falls" set in Saberhagen's Berserker universe. Your question has elements that are similar to this.
You can read the book online here
It may be one of the novels from Anne McCaffery's Brainship series.
The concept brainship in science fiction literature refers to an interstellar starship that is created by inserting the disembodied brain and nervous system of a human being into a life-support system, and connecting it surgically to a series of computers via delicate synaptic connections (a brain-computer interface.) The brain "feels" the ship (or any other connected peripherals) as part of its own body. Flying, taking off, landing, and controlling all the other features of the ship are as natural as moving, breathing and talking are to an ordinary human. Being wired into a computer speeds their reactions, but still allows their human brains to make intelligent decisions based on calculations.
The Brain & Brawn Ship series comprises seven novels, only the first of which (a fix-up of five previously published stories) was written by McCaffrey alone. The stories in this series deal with the adventures of "shell-people" or "Brains", who as infants (due to illness or birth defects) have had to be hard-wired into a life-support system. With sensory input and motor nerves tied into a computer they serve as starship pilots (or colony administrators), seeing and feeling the colony or ship as an extension of their own body. They perform this job to pay off their debt for education and hardware, and continue as free agents once the debt is paid. To compensate for the Brains' inability to move within human habitats they are paired with partners known as "Brawns", who are trained in a wide array of skills (including the protection of their Brain counterparts). It was considered impossible for a person to adjust to being a shell after the age of two or three. An exception, in The Ship Who Searched, was a shell-person who was seven when she became quadriplegic.
List of novels in the series -
The Ship Who Sang (1969) (fix-up of stories from 1961, 1966, and 1969)
PartnerShip (1992) with Margaret Ball
The Ship Who Searched (1992) with Mercedes Lackey
The City Who Fought (1993) with S.M. Stirling
The Ship Who Won (1994) with Jody Lynn Nye
This series also includes solo entries by Stirling and Nye
The Ship Errant (1996) by Jody Lynn Nye
The Ship Avenged (1997) by S.M. Stirling
A link to the series on good reads - https://www.goodreads.com/series/40397-brainship