Ubuntu Installation and Configuration SSH Server

本文参考自:http://www.centospub.com/make/sshd.html

apt-get install ssh openssh-server

vi /etc/ssh/sshd_config  ← 用vi打开SSH的配置文件

/etc/rc.d/init.d/sshd restart  ← 重新启动SSH服务器

$ ssh-keygen -t rsa  ← 建立公钥与私钥
Generating public/private rsa key pair.
Enter file in which to save the key (/home/kaz/.ssh/id_rsa):  ← 钥匙的文件名,这里保持默认直接回车
Created directory '/home/kaz/.ssh'
Enter passphrase (empty for no passphrase):  ← 输入口令
Enter same passphrase again:   ← 再次输入口令
Your identification has been saved in /home/kaz/.ssh/id_rsa.
Your public key has been saved in /home/kaz/.ssh/id_rsa.pub.
The key fingerprint is:
tf:rs:e3:7s:28:59:5s:93:fe:33:84:01:cj:65:3b:8e centospub@sample.centospub.com

$ cd ~/.ssh  ← 进入用户SSH配置文件的目录

$ ls -l  ← 列出文件
total 16
-rw------- 1 centospub centospub 951 Sep 4 19:22 id_rsa  ← 确认私钥已被建立
-rw-r--r-- 1 centospub centospub 241 Sep 4 19:22 id_rsa.pub  ← 确认公钥已被建立

$ cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys  ← 公钥内容输出到相应文件中

$ rm -f ~/.ssh/id_rsa.pub  ← 删除原来的公钥文件

$ chmod 400 ~/.ssh/authorized_keys  ← 将新建立的公钥文件属性设置为400

复制走私钥文件,你就可以拿到别的电脑上面登陆连接了。

比如可以参考:http://www.centospub.com/make/sshcl.html 在 windows 的 putty上面远程登录 SSH


Comments are closed.