How to connect VSCode to Ubuntu (including detailed debugging for some incorrect default config)

step-by-step guide

Step 1: Install the “Remote - SSH” Extension

Install the “Remote - SSH” extension from the Visual Studio Code marketplace.
在这里插入图片描述
Step 2: Open the Remote Explorer

After installing the extension, click the “Remote Explorer” icon located below the “Extensions” icon on the sidebar.
在这里插入图片描述
Step 3: Gather Your Server Information

On your Ubuntu server, run the following commands to obtain your HostName and User name:

For this example, let’s assume they are “172.25.231.252” and “root,” respectively.

whoami
ip a

Step 4: Open the SSH Config File

Click the settings icon to open the SSH Config file. This file is often located at “~/.ssh/config”.
在这里插入图片描述
Step 5: Add Your Server to the SSH Config File

Follow the format given below, replacing the placeholders with your server information obtained in Step 3.

Host myUbuntu
  HostName 172.25.231.252
  User root

Step 6: Connect to Your Server

Click the right-most icon to connect to your server in a new window.
在这里插入图片描述
Step 7: Select Your Server’s Platform

Select “Linux” as the platform.
在这里插入图片描述
Step 8: Enter Your Password

Enter your server’s password when prompted.
在这里插入图片描述
Step 9: Connection Successful

Once connected, you should see a welcome window indicating that the connection was successful.
在这里插入图片描述

Common problems

Unable to connect to Ubuntu, resulting in no password prompt

To install the SSH server on Ubuntu, you can use the following command:

sudo apt update
sudo apt install openssh-server

Password is correct but permission is denied

In the sshd_config file content, the PermitRootLogin option is set to prohibit-password, which means that it does not allow root user login using password authentication. You need to change this option to yes and then restart the SSH service.

  1. Use a text editor to modify the sshd_config file:
sudo nano /etc/ssh/sshd_config
  1. Find the PermitRootLogin line and modify it to:
PermitRootLogin yes
  1. Save the file and exit the text editor.
  2. Restart the SSH service:
sudo service ssh restart

Setting a password in Ubuntu

To set a user password in Ubuntu, you can use the passwd command. Here are the steps to set a password:

  1. Open a terminal.

  2. Type the following command and then press Enter:

    passwd
    
  3. The system will prompt you to enter a new password, type the password you want to set, and then press Enter.

  4. The system will ask you to retype the new password for confirmation, retype the password you just entered, and then press Enter.

  5. If the two entered passwords match, the system will display passwd: password updated successfully, indicating that the password has been successfully set.

If you want to set a password for another user, you can use the following command:

sudo passwd username

And then follow the above steps to enter and confirm the password.

  • 2
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 2
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值