全新安装的linux因为默认都是国外源. 首先第一步换源这样下载软件速度会快一点.
1.由于debian系统稳定性下面列举华为和阿里的镜像源
cd /etc/apt&&cp sources.list sources.list.bak&&vi sources.list
#vim基本操作可以自行百度.直接删除原来所有源地址直接shift+insert下面源地址
华为debian镜像源
deb https://mirrors.huaweicloud.com/debian/ buster main contrib non-free
deb https://mirrors.huaweicloud.com/debian/ buster-updates main contrib non-free
阿里镜像
deb http://mirrors.aliyun.com/debian stretch main contrib non-free
deb-src http://mirrors.aliyun.com/debian stretch main contrib non-free
2.换源后更新包列表
apt-get update
3.安装ssh服务很简单运行下面代码完成.
apt-get install openssh-server
4.修改ssh配置 vi /etc/ssh/sshd_config
ssh配置
Port 22 # 默认22端口当然可以自由修改一般选择默认就好
PasswordAuthentication yes # 运行密码登录
ListenAddress 0.0.0.0 # 运行所有ip地址登录当然可以设定登录IP保证服务器安全
PermitRootLogin yes # 运行root账号登录因为root是最高权限根据个人使用习惯看开启此功能不基本的配置就完成了其他默认就好.
5.启动ssh服务 /etc/init.d/ssh start
启动ssh服务
6.linux文件传功能scp是基于ssh服务的
将远程主机文件复制到本地 scp 用户名@服务器地址 :/path /path
示例代码 :scp
192.168.1.18:/tmp/demo/f3.log /tmp/files/1.上传本机文件到远程服务器
scp local_path/file_name user_name@remote_ip:remote_path/
2.上传本机目录到远程服务器
scp -r local_path/fold_name user_name@remote_ip:remote_path/
3.拷贝远程服务器文件到本机
scp user_name@remote_ip:remote_path/file_name local_path/
4.拷贝远程服务器目录到本机
scp -r user_name@remote_ip:remote_path/folder_name local_path/
linux发送文件到Windows
7.卸载ssh服务
apt-get remove openssh-server
总结:ssh的安装,配置,文件传输,卸载基本写完。通过上面的内容基本满足在命令行使用ssh文件上传,下载.shell操作等.备注因为windows已经有ssh服务了这样通过ssh可以linux与windows之间连接操作了是不是方便了很多.
发表评论