han8809 发表于 2017-7-4 08:16:43

Linux上安装使用SSH

  參考博客:http://blog.csdn.net/xqhrs232/article/details/50960520

Ubuntu安装使用SSH

ubuntu默认并没有安装ssh服务,如果通过ssh链接ubuntu,需要自己手动安装ssh-server。判断是否安装ssh服务,可以通过如下命令进行:

    xjj@xjj-desktop:~$ ssh localhost   
ssh: connect to host localhost port 22: Connection refused

  如上所示,表示没有还没有安装,可以通过apt安装,命令如下:

  xjj@xjj-desktop:~$ sudo apt-get install openssh-server

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

  xjj@xjj-desktop:~$ sudo /etc/init.d/ssh start
  
  启动后,可以通过如下命令查看服务是否正确启动
  xjj@xjj 621200:00 sshd
  621200:00 sshd
  
  如上表示启动ok。注意,ssh默认的端口是22,可以更改端口,更改后先stop,

  然后start就可以了。改配置在/etc/ssh/sshd_config下,如下所示。

[*]-desktop:~$ vi /etc/ssh/sshd_config
[*]# Package generated configuration file
[*]# See the sshd(8for details
[*]# What ports, IPs and protocols we listen for 22

  最后,应该是连接的时候了。请看如下命令:
  xjj@xjj.168.158.129

客戶端 安裝ssh 啓動連接後,錯誤
  Server responded"Algorithm negotiation failed
  修改ssh的配置文件 /etc/ssh/sshd_config



在配置文件中添加:
  Ciphers aes128-cbc,aes192-cbc,aes256-cbc,aes128-ctr,aes192-ctr,aes256-ctr,3des-cbc,arcfour128,arcfour256,arcfour,blowfish-cbc,cast128-cbc

MACs hmac-md5,hmac-sha1,umac-64@openssh.com,hmac-ripemd160,hmac-sha1-96,hmac-md5-96

KexAlgorithms
diffie-hellman-group1-sha1,diffie-hellman-group14-sha1,diffie-hellman-group-exchange-sha1,diffie-hellman-group-exchange-sha256,ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521,diffie-hellman-group1-sha1,curve25519-sha256@libssh.org
  重启sshd服务后,即可正常连接。
  sudo service ssh restart
  另外重启方式还有sudo /etc/init.d/ssh restart
  參考博客:http://www.linuxdiyf.com/linux/24314.html
页: [1]
查看完整版本: Linux上安装使用SSH