Pycharm配置ssh实现在linux server(ubuntu 16.04)上调试和开发

Pycharm可以通过ssh(Secure Shell)远程访问服务器,通过Tool–>>Start SSH Session–>>Edit credentials,填写Host,User name,Password等即可登录,完成常见的Linux命令行操作。本文主要是基于SSH Interpreter,实现Pycharm在Linux server上远程调试。

一、配置SSH Interpreter

1 选择本地Project–>>打开Setting(CTRL + ALT + S)–>>选择Project Interpreter–>>Add…

Pycharm配置ssh实现在linux server(ubuntu 16.04)上调试和开发

2 选择SSH Interpreter–>>第一次连接server,这里选择New server configuration–>>填写Host, Username–>>Next

Pycharm配置ssh实现在linux server(ubuntu 16.04)上调试和开发

3 输入密码–>>Next

Pycharm配置ssh实现在linux server(ubuntu 16.04)上调试和开发

4 配置interpreter与Sync folders

a) Interpreter设置Linux server上已经配置好的环境py37_2–>> /home/lollows/anaconda3/envs/py37_2/bin/python3.7
b) 选择Execute code using this interpreter with root privilege via sudo
c) 设置Sync folders–>>/home/lollows/cs231n/Assignment1
d) 取消Automatically upload project files to the server还是自动同步吧,手动太麻烦了
e) Finish
Pycharm配置ssh实现在linux server(ubuntu 16.04)上调试和开发

5 完成

这时在Pycharm中可以看到Linux server上的环境py37_2内部的Package–>OK
Pycharm配置ssh实现在linux server(ubuntu 16.04)上调试和开发
等待Deployment configuration has been created
Pycharm配置ssh实现在linux server(ubuntu 16.04)上调试和开发

查看与同步文件

选择Tools–>Deployment–>>Browse Remote Host,即可查看服务器的文件目录树
Pycharm配置ssh实现在linux server(ubuntu 16.04)上调试和开发
Pycharm配置ssh实现在linux server(ubuntu 16.04)上调试和开发
可以看到服务器端Sync folders(Assignment1)还没有文件,通过Tools–>>Deployment–>>Upload here就可以在服务器端看到文件了
Pycharm配置ssh实现在linux server(ubuntu 16.04)上调试和开发