Configuring a Remote SSH Server in PyCharm

Obtain Ubuntu Server IP Address

Two ways of obtaining IP Address

  1. Obtaining an IP address using the ‘ifconfig’ command in server terminal:
ifconfig 

Sample output:

enolnp0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
         inet 192.168.1.10  netmask 255.255.255.0  broadcast 192.168.1.255
         inet6 fe80::a00:27ff:fe5c:ebac  prefixlen 64  scopeid 0x20<link>
         ether 08:00:27:5c:eb:ac  txqueuelen 1000  (Ethernet)
         RX packets 26284  bytes 2144348 (2.1 MB)
         RX errors 0  dropped 0  overruns 0  frame 0
         TX packets 24776  bytes 1939930 (1.9 MB)
         TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

In the example above, the server’s IP address is displayed as 192.168.1.10 under ‘inet’.

  1. Using the ‘hostname’ command to obtain the IP address:
hostname -I

Sample output:

192.168.1.10

Set Up SSH Configurations

In PyCharm, navigate to ‘Settings…’ -> ‘Tools’ -> ‘SSH Configurations’. To set up a new configuration, click the ‘+’ button. Enter the following details:

Host: Use the IP address obtained earlier.
Port: By default, this will be 22.
Username: Enter the system username of the server.
Password: Input the user login password for the server.

Ensure the ‘Save password’ option is checked.

Additionally, under ‘Connection Parameters’, make sure the option ‘send keep-alive messages every () seconds’ is both filled out and ticked.
SSH Configurations

Set Up SSH Connection for New Project

Create a new project. In the ‘Location’ tab, specify the directory for your project. Next, under ‘Python Interpreter’, choose ‘Previously configured interpreter’. Then, click on the ‘’ button.

New Project

'Remote project location' refers to the directory on the server where you want to store your files.

Under ‘SSH Interpreter’, choose ‘Existing server configuration’. Then, from the dropdown list, select the SSH configuration that you created in the ‘Setup SSH Configurations’ section.

Add Python Interpreter_1

Choose the interpreter directory located on the server. Ensure that the option ‘Execute code using this interpreter with root privileges via sudo’ is selected.

Add Python Interpreter_2

After clicking “Finish”, you’ll return to the “New Project” page. Proceed by clicking “Create”.

Next, navigate to "Tools" and select “Deployment”. Ensure that the “Automatically Upload” option is checked.

在这里插入图片描述

Set Up SSH Connection for Existing Project

Navigate to ‘Settings’ or ‘Preferences’, then under ‘Project: [Your Project Name]’, choose ‘Python Interpreter’. Next, click on the settings (gear) icon adjacent to the ‘Python Interpreter dropdown’, select ‘Add…’, and follow the instructions as outlined in the ‘Set Up SSH Connection for New Project’ section.

Preference

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值