惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

月光博客
月光博客
Stack Overflow Blog
Stack Overflow Blog
L
LangChain Blog
Jina AI
Jina AI
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
雷峰网
雷峰网
T
Tailwind CSS Blog
MongoDB | Blog
MongoDB | Blog
博客园 - 【当耐特】
博客园 - 聂微东
V
Visual Studio Blog
博客园_首页
Engineering at Meta
Engineering at Meta
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
The Cloudflare Blog
人人都是产品经理
人人都是产品经理
Apple Machine Learning Research
Apple Machine Learning Research
阮一峰的网络日志
阮一峰的网络日志
Microsoft Security Blog
Microsoft Security Blog
GbyAI
GbyAI
F
Fortinet All Blogs
C
Check Point Blog
罗磊的独立博客
H
Hackread – Cybersecurity News, Data Breaches, AI and More

jdhao's digital space

Conversion between base64 and OpenCV or PIL Image 腾讯云对象存储博客图床开启 CDN 加速(不需要购买额外域名) Search and Replace in Multiple Files in Vim/Neovim Change Table Column Width in LaTeX Image or Table Side by Side in LaTeX LaTeX 并排显示图像或表格 Firenvim: Neovim inside Your Browser Content inside HTML tags missing in Latest Hugo? Creating Markdown Front Matter with Ultisnips Labelme JSON 标注格式转 voc XML 格式 Nifty Nvim Techniques That Make My Life Easier -- Series 6 macOS 下如何为视频制作字幕 Running Command Asynchronously inside Neovim Resolving Merge Conflict after Git Stash Pop Pylint: command not found? A Hands-on Experience with Neovim's Built-in LSP Support How to Convert PDF to Images with Imagemagick 互联网上常用缩略语集锦 File Backup in Neovim Converting PDF Pages to Images with Poppler Nifty Nvim Techniques That Make My Life Easier -- Series 5 Neovim Configuration for System-wide Use How to sort a list of tuple or list in Python -- lambda or itemgetter? Building A Vim Statusline from Scratch 人类第一颗原子弹爆炸始末 Distributed Training in PyTorch with Horovod Learning Expect Programming Essential Knowledge about SSH Nifty LaTeX Techniques -- Series 1 更改 Adsense 邮寄地址,重新寄送 PIN
Set up X11 Forwarding with Git for Windows (git-bash)
2018-03-02 · via jdhao's digital space

As I have posted earlier, Cmder is a better option if you use Windows command line frequently. The full installation of Cmder comes with Git for Windows, which is handy to provide a Linux-like environment. In this post, I will write about how to use Git for Windows to connect to a remote CentOS server and set up X11 forwarding to use the GUI applications on that server.

Enable X11 forwarding on your CentOS server#

First, you need to make sure that your server support X11 forwarding. Edit the file /etc/sshd_config and use the following settings:

X11Forwarding yes
X11DisplayOffset 10
X11UseLocalhost no

If you are using CentOS 7, you should use

systemctl restart sshd.service

to restart the sshd service. If you are on CentOS 6, you should use the following command instead:

Install X server program on Windows#

In order to use X11 forwarding, you also need to install a X server on your Windows computer. You can choose to install xming or vcxsrv. Vcxsrv is better since it is updated frequently and is free, while latest version of xming requires a license. There is a good post that introduces vcxsrv.

In this post, we stick to vcxsrv. Install the application, and you will see two program: xlaunch and vcxsrv. Xlaunch is used to configure the X server and vcxsrv is used to start the server. Open xlaunch and use the default settings. Then start vcxsrv. The program will run in the background. Go to the task bar and point to program, you will see information like the following:

JD-PC:0.0 - 0 clients

Configure ssh#

After starting the X server, we need to configure the ssh.

First, open git-bash, change directory to $HOME and create .bash_profile, write following options in the .bash_profile

export DISPLAY=localhost:0.0

Save the file and restart git-bash.

Second, connect to your remote server using the following command:

ssh -X -v <user>@<server_addresss>

The option -v is used to diagnose the X connection problems.

Trouble shotting#

After logging into your server, you may notice a warning message during login:

Warning: untrusted X11 forwarding setup failed: xauth key data not generated

If you try to start a GUI program, e.g., xclock, you may see an error message:

Error: Can’t open display:

If that is the case, close the session and try to use the following command to connect to your server instead:

ssh -Y -v <user>@<server_addresss>

Rerun the xclock program with xclock &. It should works fine.

We can run multiple GUI applications, for example xclock &, xeyes &. If you point to vcxsrv icon in the task bar, you will see that now it has 2 clients:

JD-PC:0.0 - 2 clients


References#