测试is-programmer服务器地点
linux查找某个文件或命令所在目录

ssh服务

yichen posted @ 2014年6月10日 16:40 in Essay , 1736 阅读

ssh为 secure shell的缩写,其为建立在应用层和传输层基础上的安全协议,是目前较为安全的网络服务程序。

下面主要介绍一下在Ubuntu系统下的安装和加密。

一、安装

联网终端敲进命令

$ sudo apt-get install openssh-server 

系统将自动进行安装,安装完成以后,先启动服务

$ sudo /etc/init.d/ssh start  

$ sudo /etc/init.d/ssh start

启动后,可以通过如下命令查看服务是否正确启动

$ ps -e|grep ssh   

6212 ?        00:00:00 sshd  

$ ps -e|grep ssh 6212 ? 00:00:00 sshd

如上表示启动ok。注意,ssh默认的端口是22,可以更改端口,更改后先stop,然后start就可以了。

更改配置在/etc/ssh/sshd_config下,如下所示。

$ vi /etc/ssh/sshd_config   

# Package generated configuration file

# See the sshd(8) manpage for details

# What ports, IPs and protocols we listen for

Port 22

二、连接

与服务器连接

$ ssh 主机名@IP地址  

文件拷贝
 
$ sudo scp 主机名@IP地址:/文件路径
 
三、加密与无密连接
 
1.client端生成公钥和密钥

 

我们使用RSA密钥认证的目的是:从client端登陆server端时,不需要密码认证。

所以,我们在进行认证时首先需要在client端建立属于client端自己的一对密钥(公钥和私钥),建立方法如下:

在命令行下执行:$ ssh-keygen 

执行过程中,它先要求你确认保存公钥的位置(默认为:.ssh/id_rsa),

然后它会让你重复输入一个密码两次,如果不想在使用公钥的时候输入密码,可以留空

执行完毕后,就会生成数据client端的一对密钥。

 

SSH 密钥默认储存在账户的家目录下的 ~/.ssh 目录中

关键是看有没有用 xxx_rsa 和 xxx_rsa.pub 来命名的一对文件,有 .pub 后缀的文件就是公钥,另一个文件则是密钥。

2.将Client端的公钥添加到用于认证的Server端的公钥文件中

 

首先检查Server端需要认证的phenix用户的家目录下,隐藏目录“ssh”目录下是否存在一个名为“authorized_keys”的文件,

若不存在,使用命令:touch authorized_keys 创建一个空文件

创建完成后,则可以执行如下步骤:

 

执行步骤如下:

1)将Clinet端公钥的内容复制

2)将复制到的Client端公钥内容,粘贴至Server端刚才创建的 authorized_keys 文件中,保存文件。

3)更改 authorized_keys 文件的权限

执行命令:chmod 600  authorized_keys

3.验证无密码登陆

 

在Client端命令行执行如下命令:

ssh -p12  phenix@10.2.31.33     (本例ssh服务开在了12端口,默认为22)

 

直接登陆至Server端,表示验证成功。

注意:

1)ssh-keygen执行完毕后一定要检查下phenix用户家目录下.ssh目录中是否有一对密钥

2)在将公钥粘贴至Server端后,一定要修改authorized_keys文件的权限为600,否则认证会失败

3)Server端需要开启SSH服务,不然客户端使用ssh连接不上

Avatar_small
AP 10th Maths Model 说:
2022年9月10日 21:07

Mathematics is one of the tough subjects and also an easy subject for class 10th standard students of TM, EM, AP 10th Maths Model Paper UM and HM studying at government and private schools of the state. Department of School Education and teaching staff of various institutions have designed and suggested the Mathematics question paper with solutions for all chapters topic wide for each lesson of the course, and the AP SSC Maths Model Paper 2023 Pdf designed based on the new revised syllabus and curriculum.


登录 *


loading captcha image...
(输入验证码)
or Ctrl+Enter