ubuntu版本scp连接Permission denied, please try again.问题

scp依赖于ssh服务

1.scp连接到ubuntu版本时,使用的用户必须有操作目录的权限:

例:scp /etc/my.cnf  mysql@192.168.2.100 /etc/

192.168.2.100主机的mysql用户,必须得有/etc目录的操作权限,一般给全权限7

2.如果是以root用户连接的话,这个时候得去修改ssh的配置文件,因为ubuntu上面安装ssh时,默认是不允许以root用户链接的。

例如:scp /etc/my.cnf  root@192.168.2.100  /etc

修改192.168.2.100上/etc/ssh/sshd_config文件,部分内容:

vim sshd_config

# default value.

Port 22
#AddressFamily any
#ListenAddress 0.0.0.0
#ListenAddress ::

#HostKey /etc/ssh/ssh_host_rsa_key
#HostKey /etc/ssh/ssh_host_ecdsa_key
#HostKey /etc/ssh/ssh_host_ed25519_key

# Ciphers and keying
#RekeyLimit default none

# Logging
#SyslogFacility AUTH
#LogLevel INFO

# Authentication:

LoginGraceTime 100m
#PermitRootLogin prohibit-password
PermitRootLogin yes
StrictModes yes
#MaxAuthTries 6
#MaxSessions 10

#PubkeyAuthentication yes

3.重启ssh服务

root@debian:/etc/ssh# service ssh restart
root@debian:/etc/ssh# service sshd restart

端口链接问题

链接远程ssh22端口时被拒绝,这个时候第一个要干的是先检查ssh服务是否安装,主机是否监听22端口,上面正常后还是链接不上 这时候就去看防火墙,解决防火墙的问题。
原文地址:https://www.cnblogs.com/wonchaofan/p/13344449.html