怎么把网站放到服务器上,站长工具seo综合查询外部链接数量,长春网站建设网诚传媒,温岭网站建设制作目录
1. powershell 生成key#xff1a;
2. 在服务器上安装公钥
3).为了确保连接成功#xff0c;输入如下指令以保证以下文件权限正确#xff1a;
3 开启 ssh 密钥登录
vscode 远程连接配置
python连接
python实现 1. powershell 生成key#xff1a;
在命令行执行s…目录
1. powershell 生成key
2. 在服务器上安装公钥
3).为了确保连接成功输入如下指令以保证以下文件权限正确
3 开启 ssh 密钥登录
vscode 远程连接配置
python连接
python实现 1. powershell 生成key
在命令行执行ssh-keygen来创建密钥对默认情况下会生成一个私钥id_rsa和一个公钥id_rsa.pub
一般保存目录
C:\Users\xxxx\.ssh 2. 在服务器上安装公钥
1). 拷贝id_rsa.pub中的公钥并添加到authorized_keys中
mkdir -p ~/.ssh
# {YOUR_PUB_KEY}是拷贝的公钥以ssh-rsa开头
echo {YOUR_PUB_KEY} ~/.ssh/authorized_keys
2). 把 id_rsa.pub文件拷贝到服务器上
执行覆盖
cat id_rsa.pub ~/.ssh/authorized_keys
执行追加
cat id_rsa.pub ~/.ssh/authorized_keys 如此便完成了公钥的安装。
3).为了确保连接成功输入如下指令以保证以下文件权限正确
cd /root/.sshchmod 600 authorized_keys
chmod 700 ~/.ssh
方法2
chmod 600 /root/.ssh/authorized_keys
chmod 700 /root/.ssh 3 开启 ssh 密钥登录
vim /etc/ssh/sshd_config 将 PubkeyAuthentication 和 AuthorizedKeysFile 这两个选项的注释取消掉AuthorizedKeysFile 选项后面的路径指定了从哪里读取公钥文件 修改完毕重启远程服务器
vscode 远程连接配置
Host xxxxHostName xxxUser xxxPort xxxIdentityFile C:\Users\xxx\.ssh\id_rsa 原文链接https://blog.csdn.net/TheKoi/article/details/129571955 python连接
ssh-keygen -t rsa -b 2048 -C your_emailexample.com import paramiko # 导入paramiko库# 创建SSHClient实例
ssh paramiko.SSHClient()
# 自动添加未在known_hosts文件中的主机
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy()) # 通过密钥进行连接
try:ssh.connect(hostnameyour_windows_ip, usernameyour_username, key_filenamepath_to_your_private_key) # 连接到Windowsprint(连接成功)# 执行命令stdin, stdout, stderr ssh.exec_command(dir) # 执行Windows命令print(stdout.read().decode()) # 打印命令输出except Exception as e:print(f连接失败: {e}) # 处理异常finally:ssh.close() # 关闭SSH连接 python实现
ssh-copy-id for Windows.
Example usage: python ssh-copy-id.py ceilforsmy-remote-machine
This script is dependent on msysgit by default as it requires scp and ssh.
For convenience you can also try that comes http://bliker.github.io/cmder/.#ssh-copy-id.py
import argparse, os
from subprocess import calldef winToPosix(win):Converts the specified windows path as a POSIX path in msysgit.Example:win: C:\\home\\userposix: /c/home/userposix win.replace(\\, /)return / posix.replace(:, , 1)parser argparse.ArgumentParser()
parser.add_argument(-i, --identity_file, helpidentity file, default to ~\\.ssh\\idrsa.pub,defaultC:\\Users\\Administrator\\.ssh\\id_rsa.pub)
parser.add_argument(-d, --dry, helprun in the dry run mode and display the running commands.,actionstore_true)
parser.add_argument(remote, metavarusermachine)
args parser.parse_args()local_key winToPosix(args.identity_file)
remote_key ~/temp_id_rsa.pub# Copy the public key over to the remote temporarily
scp_command scp {} {}:{}.format(local_key, args.remote, remote_key)
print(scp_command)
if not args.dry:call(scp_command)# Append the temporary copied public key to authorized_key file and then remove the temporary public key
ssh_command (ssh {} mkdir ~/.ssh;touch ~/.ssh/authorized_keys;cat {} ~/.ssh/authorized_keys;rm {};).format(args.remote, remote_key, remote_key)
print(ssh_command)
if not args.dry:call(ssh_command) 重启服务sudo service ssh restart 查看日志
cat /var/log/auth.log