Ubuntu -ssh
Ubuntu -ssh
Ubuntu -ssh
Ubuntu -ssh
安装客户端
1 | sudo apt install openssh-client |
安装服务端
1 | sudo apt install openssh-server |
配置
1 | 查看手册 man sshd_config |
在编辑配置文件之前,您应该生成一个原始文件的拷贝并对其写保护,以便您可以参考原始文件并在必要时重用它。拷贝 /etc/ssh/sshd_config 文件并对其写保护可以通过在终端提示符后运行下列命令
1 | sudo cp /etc/ssh/sshd_config /etc/ssh/sshd_config.original |
要设置您 OpenSSH 在 TCP 2222 端口而不是缺省的 TCP 20 端口监听,可以如下使用改变 Port 语句:
Port 2222
要让 sshd 允许基于公钥登录证书,可以简单添加或修改该行语句:
PubkeyAuthentication yes
If the line is already present, then ensure it is not commented out.
要使您的 OpenSSH 服务器显示 /etc/issue.net 文件的内容以作为预登录 Banner,只需简单地将下行添加或修改:
Banner /etc/issue.net
在 /etc/ssh/sshd_config 文件中。
在修改 /etc/ssh/sshd_config 文件之后,保存该文件并重启 sshd 服务器应用程序以使之生效。可以在终端提示符后使用下列命令:
1 | sudo systemctl restart sshd.service |
SSH服务器命令
1 | 停止服务:sudo /etc/init.d/ssh stop |
如果细心,可能发现远程登录不能用root登录,解决办法: 修改 /etc/ssh/sshd_config 配置文件
1 | 26 # Authentication: |
其他
证书登录、无密码登录这里不在写,有需要的自己网上找资料;这个也是修改 sshd_config 文件
扩展:
Ubuntu ssh