Ubuntu server LTS 16.04安装SSH以及连接问题

时间:2023-03-08 23:28:21
Ubuntu server LTS 16.04安装SSH以及连接问题

1、SSH安装

出现问题:

登录到Ubuntu服务器,执行以下命令:

sudo apt-get install openssh-server

出现以下错误:

Ubuntu server LTS 16.04安装SSH以及连接问题

解决办法:

1)确保服务器能出外网,比如说ping www.baidu.com,如果返回正常,说明能正常访问公网,这样子才能更新并下载安装包

2)执行命令:sudo apt-get update

3)执行命令:sudo apt-get install openssh-server,输入y确认进行安装;



2、使用secureCRT连接root以及用户失败

出现异常:

The server has disconnected with an error. Server message reads:

A protocol error occurred. Change of username or service not allowed: (root,ssh-connection) -> (zoujiaqing,ssh-connection)

解决办法:

1)执行命令:vim /etc/ssh/sshd_config

将PermitRootLogin修改成yes

2)重启SSH服务:service ssh restart



3、使用SSH Secure File Transfer连接到Ubuntu服务失败;

连接异常:

Ubuntu server LTS 16.04安装SSH以及连接问题

解决办法:

1)执行命令:sudo vi /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

2)重启SSH:sudo /etc/init.d/ssh restart

3)再次连接