Linux如何设置SSH Key登录?

1、生成ssh公钥和私钥,执行如下命令: ssh-keygen -t rsa 在生成过程中可以根据需要设置一个passphrase,也可以不设置。 2、生成完成后,会有相应的文件 id_rsa id_rsa.pub 3、将id_rsa.pub拷贝到目标服务器的~/.ssh目录 4、将公钥文件制成验证key,删除公钥文件 cat id_rsa.pub >> authorized_keys rm -rf id_rsa.pub 5、尝试登录,将不需要密码,如果设置了passphrase,则需要输入这个密码

开放端口

ubuntu下开放端口主要有两种办法: 自带的防火墙 使用iptables 安装iptables: $ sudo apt-get install iptables   添加规则: $ sudo iptables -I INPUT -p tcp –dport 80 -j ACCEPT   保存规则 $ sudo iptables-save   持久化iptables iptables-save只是暂时保存了端口的开放规则,如果关机或者重启,那么刚才添加的规则就会失效。 使用iptables-persistent可以对端口的开放规则进行持久化操作,使其永久保持有效。   安装iptables-persistent $ sudo apt-get install iptables-persistent   持久化规则 $ sudo netfilter-persistent save $ sudo netfilter-persistent reload   出处:https://blog.csdn.net/pcf1995/article/details/81082491

win10下Linux子系统开启ssh服务

安装ssh apt-get install openssh-server 修改sshd配置文件 sudo cp /etc/ssh/sshd_config /etc/ssh/sshd_config.bak 修改内容: Port 23 # 端口改为23,22端口已被系统占用 ListenAddress 0.0.0.0 # 取消注释 #StrictModes yes # 注释 PasswordAuthentication yes # 允许密码登录 启动ssh service ssh start 如果提示sshd error: could not load host key,则用下面的命令重新生成 sudo rm /etc/ssh/ssh*key dpkg-reconfigure openssh-server 出处:http://www.it1352.com/725354.html