International Harvester Co. and its 225 banks are nearing agreement on a complicated realignment of the $3.4 billion in debt of the giant manufacturer of farm equipment and trucks, sources close to the negotiations said today.

The deadline for all banks to sign the agreement is midnight Wednesday.

"There are a few hold-out banks," said one banker close to the negotiations. "But I expect them to come on board. I'm optimistic we'll have a deal in hand by Wednesday."

If the agreement falls through, Harvester--which was founded in 1831 by American inventor Cyrus McCormick--likely would be forced to file for bankruptcy. Rumors that the Chicago giant was ready to ask the courts to protect it from its creditors have cropped up regularly over the last three months. "I hear the rumor about every two weeks," said a major banker. "I'd sure know if they were true."

Even if the banks and Harvester reach agreement--the holdout banks are reported to be small lenders to Harvester--the company probably will need more cash to keep it going until interest rates come down and sales improve.

Harvester's problems began on Nov. 1, 1979, when the company decided to take a strike by the United Auto Workers. The marathon affair lasted 172 days, with both sides claiming victory. But during the strike, Harvester began to go into debt, and at the same time lost about $400 million in potential profits.

By the time the strike was settled, Harvester's main customers--farmers, construction companies and truck companies--were in a severe recession. With sales depressed, the company's debt kept climbing, going from $450 million just before the strike to $3.4 billion today.

In fiscal 1981, which ended Oct. 31, the company lost $636 million on its continuing operations and had sales of $7 billion compared with a loss a year ago of $397.3 million on sales of $6.3 billion. Harvester's sale of its Solar Turbine division to its competitor, Caterpillar Tractor Co., reduced the net loss by $276 million.

The company has undertaken severe cost-cutting measures, including sharp layoffs, freezing of white collar salaries and a cut of 20 percent in executive salaries.

The proposed loan restructuring would change short-term loans into two-year term loans and reduce the amount of interest Harvester has to pay.

Bankers say they are convinced that if Harvester is given time, it again will be profitable. "They've got good products," said one major banker. "When their markets come back, the company will be all right."

Harvester has spent more than $1 billion in the last three years to upgrade and modernize its facilities and has introduced a new line of trucks and tractors this year. Harvester said that by converting the short-term debt into two-year loans, it will get the breathing space it needs. To make it easier for the banks to change the terms of the loans, Harvester said it would put up Harvester plants as collateral. The company had been reluctant to post collateral in earlier loan negotiations.

The eight banks on the Harvester loan advisory committee--Bank of America, Bank of Montreal, Chase Manhattan, Continental Illinois, Deutsche Bank, Lloyds Bank International, Manufacturers Hanover and Morgan Guaranty--agreed on the new proposal in October and sent it off to the remaining 217 banks in November.

Bankers said that the few holdout banks, whom they would not identify, are under heavy pressure to go along. "They will," said one banker confidently.