您的位置:首页 > 其它

如何通过Cygwin的ssh远程访问其他服务器

2014-12-20 21:17 477 查看

转载自:http://x.cygwin.com/docs/ug/using-remote-apps.html

Displaying remote X clients with Cygwin/X is identical to displaying remote X clients with any other X Server.

It is recommended that you use the secure method of tunnelling the X connection over ssh.
Alternatively, you can use the host-based access control provided by the X server, connecting to the remote machine using telnet or rsh and
directing clients to connect to the server by setting the DISPLAY environment variable. This method is insecure and not recommended.


Secure ssh


On your Windows machine:

Make sure you have the openssh package installed.

Launch Cygwin/X

Ensure the DISPLAY environment variable is set correctly. (This step is not neccessary if you are entering your commands into an X terminal, as DISPLAY must already be set in that case)

$ export DISPLAY=:0.0

Run the ssh command to connect to the remote host:

$ ssh -Y username@remote_hostname_or_ip_address

Enter your password when prompted by ssh.

Your ssh session should now show you a shell prompt for your remote machine.

Note: The ssh server will automatically set the DISPLAY environment variable appropriately, typically to something like localhost:10.0, so clients will connect to a proxy X11 display on the remote host from which
the X11 protocol will be forwarded over ssh to your X server.

If your login scripts unconditionally set DISPLAY to something else, this will break X11 forwarding.

You can now launch remote X clients in your ssh session, for example:

$ xterm &

will launch an xterm running on your remote host that will display on your Cygwin/X screen.

Launch other remote clients in the same manner. I recommend starting the remote clients in the background, by appending & to the command name, so that you don't have to open several ssh sessions.

Note: By default, the OpenSSH server does not allow forwarded X connections. This must be configured on the remote host by adding X11Forwarding yes to the sshd_config configuration file.
The OpenSSH server must be restarted or SIGHUP'ed to re-read the configuration file after it is changed.

Note: The OpenSSH server requires the xauth command to be available to forward X connections. Consequently, it must be installed on the remote host.
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: