使用SSH 从Windows连接到Ubuntu

前两篇文章分别介绍过

这篇文章要介绍通过SSH, 从Windows上登陆Ubuntu.

在Ubuntu上

首先安装并开启SSH Server:

$ sudo apt-get install openssh-server

在Windows上

首先下载安装Cygwin, 注意安装的时候也要勾选SSH模块。

然后生成Key Pair:

$ ssh-keygen

将Public Key拷贝到Ubuntu上面

$ scp id_rsa.pub your_user_name@${ubuntu_ip}:/tmp/id_rsa.pub

第一次先用密码通过SSH登陆到Ubuntu

$ ssh your_user_name@${ubuntu_ip}

然后将Public Key拷贝到authorized_keys

$ cat /tmp/id_rsa.pub >> ~/.ssh/authorized_keys

最后修改SSH config. 这样就可以使用Key Pair 登陆了,不需要每次再输入密码了。

$ sudo vim /etc/ssh/sshd_config

PasswordAuthentication yes 改为 PasswordAuthentication no.

重起SSH Server.

$ service ssh restart