Solution to failure to connect to remote Ubuntu via ssh

Source: Internet
Author: User
Tags openssh server

Solution to failure to connect to remote Ubuntu via ssh

Recently, many users have been unable to remotely log on to the newly installed Ubuntu Virtual Machine on VMWare. Now, the problem is found, so the solution to this problem is recorded for future use.

I. Preparation for remote logon to the VM:

The connection mode of Ubuntu virtual machines should be Bridged (Bridge Mode). You can configure static IP addresses in Ubuntu or use a router (you can use a Wi-Fi connection and configure it through a wireless router) use the DCHP server to allocate IP addresses. (generally, the IP address is not changed after configuration. Use MAC address recognition to allocate IP addresses unless the IP address is exhausted ). For more information about VMWare's networking methods, see the differences between bridge, nat, and host-only in vmware.

You can configure the NIC in Edit> Virtual Network Editor of VMWare.

P.s. In Ubuntu, you can use the commands # ifup {interface} and # ifdown {interface} to enable and disable related NICs. However, if you use ifconfig eth0 to set or modify the network interface, you cannot disable it in ifdown eth0 mode. Because ifdown will analyze and compare whether the current network parameters match the ifcfg-eth0, if not, it will give up this operation. Therefore, you must use ifconfig eth0 to disable the ifconfig eth0 operation after the ifconfig modification is complete.

Ii. Some configurations on the remote host (Ubuntu:

You must install the openssh-server software to connect to the Ubuntu virtual machine through ssh.

Installation command: sudo apt-get install openssh-server.

Sudo/etc/init. d/ssh restart (restart the ssh service)

For details, refer to: install OpenSSH Server in Ubuntu and remotely connect to Ubuntu on the client.

After openssh-server is installed, run the following command: netstat-an | grep 22 or ps-e | grep ssh.

Check whether port 22 is in the LISTEN status or whether the ssh service is running. If yes, the ssh on the Ubuntu host is configured.

Iii. Connecting XShell to the remote host Ubuntu:

Follow the prompts to gradually configure and select 22 as the port number. Then, you can log on remotely.

P.s.

1. To display Chinese characters normally in xshell, we need to change the xshell encoding method to utf8. The specific operations are as follows:

[File]-> [open]-> select connection in the opened session, click [properties]-> [Terminal], and select utf8 In the right-side translation, then you can reconnect to the server.

2. How to transfer files from windwos to linux on a virtual machine

Method 1:

Enter rz-help

If the program "rz" is not installed yet. You can use the following command to install:

Sudo apt-get install lrzsz

Switch to the directory where you want to store files

File-> Transfer-> Send ZMODEM. In the displayed dialog box, select the File you want to Transfer.

Method 2:

Use pscp (a putty binding program) for file transmission.

In addition, I would like to talk about some advantages of using remote Logon:

1. You can customize the terminal configuration;

2. virtual machines do not have to run on the GUI;

3. easy operation, just like operating on a system terminal;

4. It is very easy to transfer files. In addition, you can copy and paste files, which is very convenient.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.