转自:https://www.aliyun.com/jiaocheng/134508.html
https://www.cnblogs.com/CGDeveloper/archive/2011/07/27/2118533.html
摘要:windows下的VMwareStation安装了ubuntu(版本不限)。想通过远程工具WinSCP上传文件,因为U盘挂载的办法太麻烦了。打开WinSCP程序,输入需要的信息,连接。显示“连接由于目标计算机积极拒绝,无法连接。”我怀疑远程服务没开启。开启远程服务器在终端界面输入:servicesshdstart。结果显示:ssh:unrecognizedservice。输入查看命令:servicesshstatus显示也是unrecognizedservice。这个时候察觉windows下的VMware Station安装了ubuntu(版本不限)。想通过远程工具WinSCP上传文件,因为U盘挂载的办法太麻烦了。 打开WinSCP程序,输入需要的信息,连接。 显示“连接由于目标计算机积极拒绝,无法连接。” 我怀疑远程服务没开启。
开启远程服务器
在终端界面输入:service sshd start。
结果显示:ssh:unrecognized service。
Ubuntu下”sshd:unrecognized service”
输入查看命令: service ssh status
显示也是 unrecognized service。
Ubuntu下”sshd:unrecognized service”
这个时候察觉,没有开启ssh服务。
开启ssh服务:
终端界面键入:sudo /etc/init.d/ssh restart
(或sudo /etc/init.d/ssh start)
SSH分客户端openssh-client和openssh-server
如果你只是想登陆别的机器的SSH只需要安装openssh-client(ubuntu有默认安装,如果没有则sudo apt-get install openssh-client),如果要使本机开放SSH服务就需要安装openssh-server
sudo apt-get install openssh-server
然后确认sshserver是否启动了:
ps -e |grep ssh
如果看到sshd那说明ssh-server已经启动了。
如果没有则可以这样启动:sudo /etc/init.d/ssh start
ssh-server配置文件位于/ etc/ssh/sshd_config,在这里可以定义SSH的服务端口,默认端口是22,你可以自己定义成其他端口号,如222。
然后重启SSH服务:
sudo /etc/init.d/ssh stop
sudo /etc/init.d/ssh start
windows下使用SSH软件登录Ubuntu root用户时会出错,解决方法:
编辑ssh的配置文件etc/ssh/sshd_config
在Authentication部分,注释掉“PermitRootLogin without-password”
在Authentication部分,添加“PermitRootLogin yes”
然后重启ssh服务。
这样就可以通过ssh工具远程登录了。