SSH OpenSSH Keys

python3.7使用paramiko包连接远程主机报错:paramiko.ssh_exception.SSHException: could not get keys from ssh-agent 阅读详情

Copy From: https://help.ubuntu.com/community/SSH/OpenSSH/Keys

Public and Private Keys

 

If your SSH server is visible over the Internet, you should use public key authentication instead of passwords if at all possible. If you don't think it's important, try logging all of the malicious login attempts you get for the next week. My computer - a perfectly ordinary desktop PC - had over 4,000 attempts to guess my password and almost 2,500 break-in attempts in the last week alone. How many thousand random guesses do you think it will take before an attacker stumbles across your password?

With public key authentication, every computer has a public and a private "key" (a large number with particular mathematical properties). The private key is kept on the computer you log in from, while the public key is stored on the .ssh/authorized_keys file on all the computers you want to log in to. When you log in to a computer, the SSH server uses the public key to "lock" messages in a way that can only be "unlocked" by your private key - this means that even the most resourceful attacker can't snoop on, or interfere with, your session. As an extra security measure, most SSH programs store the private key in a passphrase-protected format, so that if your computer is stolen or broken in to, you should have enough time to disable your old public key before they break the passphrase and start using your key. Wikipedia has a more detailed explanation of how keys work.

Public key authentication is a much better solution than passwords for most people. In fact, if you don't mind leaving a private key unprotected on your hard disk, you can even use keys to do secure automatic log-ins - as part of a network backup, for example. Different SSH programs generate public keys in different ways, but they all generate public keys in a similar format:

 

<ssh-rsa or ssh-dss> <really long string of nonsense> <username>@<host>

 

 

Key-Based SSH Logins

 

Key-based authentication is the most secure of several modes of authentication usable with OpenSSH, such as plain password (the default with Ubuntu) and Kerberos tickets. Key-based authentication has several advantages over password authentication, for example the key values are significantly more difficult to brute-force, or guess than plain passwords, provided an ample key length. Other authentication methods are only used in very specific situations.

SSH can use either "RSA" (Rivest-Shamir-Adleman) or "DSA" ("Digital Signature Algorithm") keys. Both of these were considered state-of-the-art algorithms when SSH was invented, but DSA has come to be seen as less secure in recent years. RSA is the only recommended choice for new keys, so this guide uses "RSA key" and "SSH key" interchangeably.

Key-based authentication uses two keys, one "public" key that anyone is allowed to see, and another "private" key that only the owner is allowed to see. To securely communicate using key-based authentication, you need to create a public key for the computer you're logging in from, and securely transmit it to the computer you're logging in to. Wikipedia has a good explanation of the theory

Using key based logins with ssh is generally considered more secure than using plain password logins. This section of the guide will explain the process of generating a set of public/private RSA keys, and using them for logging into your Ubuntu computer(s) via OpenSSH.

 

Generating RSA Keys

 

The first step involves creating a set of RSA keys for use in authentication.

This should be done on the client.

To create your public and private SSH keys on the command-line:

 

mkdir ~/.ssh
chmod 700 ~/.ssh
ssh-keygen -t rsa

 

You will be prompted for a location to save the keys, and a passphrase for the keys. This passphrase will protect your private key while it's stored on the hard drive and be required to use the keys every time you need to login to a key-based system:

 

Generating public/private rsa key pair.
Enter file in which to save the key (/home/b/.ssh/id_rsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /home/b/.ssh/id_rsa.
Your public key has been saved in /home/b/.ssh/id_rsa.pub.

 

Your public key is now available as .ssh/id_rsa.pub in your home folder.

Congratulations! You now have a set of keys. Now it's time to make your systems allow you to login with them

 

Choosing a good passphrase

 

Just like with physical keys, you need to change all your locks if your RSA key is stolen. Otherwise, your thief will be able to get access to all your stuff.

An SSH key passphrase is a secondary form of security that gives you a little time when your keys are stolen. If your RSA key has a strong passphrase, it might take your attacker a few hours to guess by brute force. That extra time should be enough to log in to any computers you have an account on, delete your old key from the .ssh/authorized_keys file, and add a new key.

Your SSH key passphrase is only used to protect your private key from thieves. It's never transmitted over the Internet, and the strength of your key has nothing to do with the strength of your passphrase.

You have to choose for yourself whether to use a passphrase with your RSA key. Ultimately, it's a choice between cursing the difficulty every time you have to type it in, or cursing your glibness when someone logs in to all your accounts and changes your password so you can't get in any more.

If you choose to use a passphrase, pick something strong and write it down on a piece of paper that you keep in a safe place. If you choose not to use a password, just press the return key without typing a password - you'll never be asked for one again.

 

Key Encryption Level

 

Note: The default is a 2048 bit key. You can increase this to 4096 bits with the -b flag (Increasing the bits makes it harder to crack the key by brute force methods).

 

ssh-keygen -t rsa -b 4096

 

 

Password Authentication

 

The main problem with public key authentication is that you need a secure way of getting the public key onto a computer before you can log in with it. If you will only ever use an SSH key to log in to your own computer from a few other computers (such as logging in to your PC from your laptop), you should copy your SSH keys over on a memory stick, and disable password authentication altogether. If you would like to log in from other computers from time to time (such as a friend's PC), make sure you have a strong password.

 

Transfer Client Key to Host

 

The key you need to transfer to the host is the public one. If you can log in to a computer over SSH using a password, you can transfer your RSA key by doing the following from your own computer:

 

ssh-copy-id <username>@<host>

 

Where <username> and <host> should be replaced by your username and the name of the computer you're transferring your key to.

{i} Due to this bug, you cannot specify a port other than the standard port 22. You can work around this by issuing the command like this: ssh-copy-id "<username>@<host> -p <port_nr>". If you are using the standard port 22, you can ignore this tip.

You can make sure this worked by doing:

 

ssh <username>@<host>

 

You should be prompted for the passphrase for your key:

Enter passphrase for key '/home/<user>/.ssh/id_rsa':

 

Enter your passphrase, and provided host is configured to allow key-based logins, you should then be logged in as usual.

 

Troubleshooting

 

 

Encrypted Home Directory

 

If you have an encrypted home directory, SSH cannot access your authorized_keys file because it is inside your encrypted home directory and won't be available until after you are authenticated. Therefore, SSH will default to password authentication.

To solve this, create a folder outside your home named /etc/ssh/<username> (replace "<username>" with your actual username). This directory should have 755 permissions and be owned by the user. Move the authorized_keys file into it. The authorized_keys file should have 644 premissions and be owned by the user.

Then edit your /etc/ssh/sshd_config and add:

AuthorizedKeysFile    /etc/ssh/%u/authorized_keys

 

Finally, restart ssh with:

sudo service ssh restart

 

The next time you connect with SSH you should not have to enter your password.

 

username@host's password:

 

If you are not prompted for the passphrase, and instead get just the

username@host's password:

 

prompt as usual with password logins, then read on. There are a few things which could prevent this from working as easily as demonstrated above. On default Ubuntu installs however, the above examples should work. If not, then check the following condition, as it is the most frequent cause:

On the host computer, ensure that the /etc/ssh/sshd_config contains the following lines, and that they are uncommented;

 

PubkeyAuthentication yes
RSAAuthentication yes

 

If not, add them, or uncomment them, restart OpenSSH, and try logging in again. If you get the passphrase prompt now, then congratulations, you're logging in with a key!

 

Permission denied (publickey)

 

If you're sure you've correctly configured sshd_config, copied your ID, and have your private key in the .ssh directory, and still getting this error:

Permission denied (publickey).

 

Chances are, your /home/<user> or ~/.ssh/authorized_keys permissions are too open by OpenSSH standards. You can get rid of this problem by issuing the following commands:

 

chmod go-w ~/
chmod 700 ~/.ssh
chmod 600 ~/.ssh/authorized_keys

 

 

Debugging and sorting out further problems

 

The permissions of files and folders is crucial to this working. You can get debugging information from both the client and server.

if you think you have set it up correctly , yet still get asked for the password, try starting the server with debugging output to the terminal.

 

sudo /usr/sbin/sshd -d

 

To connect and send information to the client terminal

 

ssh -v ( or -vv) username@host's

 

 

Where to From Here?

 

No matter how your public key was generated, you can add it to your Ubuntu system by opening the file .ssh/authorized_keys in your favourite text editor and adding the key to the bottom of the file. You can also limit the SSH features that the key can use, such as disallowing port-forwarding or only allowing a specific command to be run. This is done by adding "options" before the SSH key, on the same line in the authorized_keys file. For example, if you maintain a CVS repository, you could add a line like this:

 

command="/usr/bin/cvs server",no-agent-forwarding,no-port-forwarding,no-X11-forwarding,no-user-rc ssh-dss <string of nonsense>...

 

When the user with the specified key logged in, the server would automatically run /usr/bin/cvs server, ignoring any requests from the client to run another command such as a shell. For more information, see the sshd man page. /755

搭建ssh服务、创建用户并授权、在RealServer创建code账号、SSH认证原理、SSH免密登录 搭建ssh服务;创建用户并授权;创建code账号;SSH认证原理;SSH免密登录; 阅读详情

相关推荐

【SSH】win11(C)免密SSH登录Ubuntu(S)

因为要在实验室服务器上创建属于自己的ssh免密连接,所以在此记录一下操作过程,方便以后复盘。主要参考的是【B站视频】【B乎文章1】【B乎文章2补充说明】本文主要记录自己实现免密操作的过程,因为师兄已经在服务器上配置好了初始的ssh服务和内网穿透。也就是说,我所做的一切都是在能通过密码进行SSH连接的情况下进行的。为了方便登录,不用每次ssh都要输入ip地址。具体操作参考 【B乎文章1。

WhiteSnakeC的博客 668

【全网最详细的Centos系统中从OpenSSH_7.4p1升级到OpenSSH_9.3p1,无需备份文件,直接干,坑已填满,亲测无问题,所需软件包都上传百度网盘】

获取OpenSSH软件包 ,链接:https://pan.baidu.com/s/16W3LIRBnB1kPbi7aZc32Og?pwd=U6SD提取码:U6SD期间踩了很多坑,特别是安装配置openssl文件的时候,一开始由于我当时版本太高了,导致很多错误,后面参考其他博客的相关文章,终于确认了openssl'的版本,并正常显示了openssl的版本,这篇文章亲测没有问题,特此记录一下,希望能帮忙到大家。

追求诗和远方的路上 1570

Windows 11 SSH密钥权限修复与OpenSSH服务配置全攻略

SSH(Secure Shell)是一种广泛使用的网络协议,通过非对称加密技术实现安全的远程登录和文件传输。其核心原理基于公钥与私钥配对,私钥文件必须保持严格的访问权限以防止未授权访问。在跨平台环境中,Windows NTFS权限模型与类Unix系统的POSIX权限标准存在差异,这导致了常见的“Permissions are too open”错误。理解并正确配置文件系统权限,不仅能解决SSH连接问题,更是保障系统安全的重要实践。本文聚焦于Windows 11平台,详细解析如何修复SSH私钥的NTFS权限冲

weixin_34378767的博客 437

SUSE-Xshell连接不到SUSE服务器

Xshell连接不到SUSE服务器(能Ping通但登录不上),执行以下命令再试: cd /etc/ssh ls vi sshd_config(输入/查找内容): PermitRootLogin yes PasswordAuthentication yes

BoomJane的专栏 3502

Windows OpenSSH配置全攻略:从安装到密钥登录与安全加固

SSH(Secure Shell)是一种广泛使用的网络协议,它通过加密技术为远程登录和文件传输提供安全保障。其核心原理是基于非对称加密体系,客户端与服务器通过密钥对进行身份验证,从而避免了密码在网络上明文传输的风险。这项技术的价值在于为系统管理员和开发者提供了安全、可靠的远程管理能力,是运维自动化、服务器管理和安全运维的基石。在Windows环境下,随着微软将OpenSSH原生集成到系统中,用户可以直接在PowerShell中使用熟悉的ssh、scp等命令,实现与Linux服务器的高效交互。本文聚焦于Win

weixin_33857230的博客 435

Windows SSH免密登录全攻略:从权限配置到安全加固

SSH(Secure Shell)是一种用于安全远程登录和文件传输的网络协议,其核心原理是通过非对称加密技术实现身份认证和数据加密。在自动化运维、持续集成和跨系统管理中,SSH免密登录能极大提升效率与安全性。相较于Linux/macOS,Windows平台的OpenSSH在文件权限模型和服务配置上存在显著差异,常导致密钥认证失败。本文聚焦于Windows 10/11及Server环境,深入解析权限设置、sshd_config配置等关键环节,通过系统性的排错指南,帮助开发者与运维人员快速搭建稳定的SSH免密通

weixin_30908941的博客 298

OpenSSH 密钥管理,第 3 部分

通用线程: OpenSSH 密钥管理,第 3 部分 代理程序转发和 keychain 改进  

思 1197

瑶芯技术分享 | 三相维也纳PFC功率器件损耗分析

电流的流通路径为:从A相电网正极流出,经过电感La,再经过二极管Da1流到直流侧电容C1,最终通过另外两相回到A相电网,具体流通路径如图2(a)所示。电流的流通路径为:从A相电网正极流出,经过电感La,再经过开关管Sa1和开关管Sa2的反向二极管流到直流侧中点N,最终通过另外两相回到A相电网,具体流通路径如图2(b)所示。通态损耗的产生是由电流正向流经IGBT 或者FRD上产生一定的压降,损耗就是正向电流和器件两端正向压降的乘积,开关损耗和反向恢复损耗则是跟开关过程中的直流电压和开关电流有关。

2301_76606324的博客 5728

python报错之paramiko.ssh_exception.SSHException: EOF during negotiation

方案1: 此方法引自https://www.cnblogs.com/lidq/p/12030662.html 查找sftp-server的位置,find / -name sftp-server 然后查看ssh的配置文件,vim /etc/ssh/sshd_config 发现路径是相同的 如果发现路径不相同,则需要重启服务 系统版本是7:systemctl restart sshd 系统版本是6:service sshd restart ...

zjjhwzl的博客 7260

AI大模型驱动的智能座舱研发体系重构

AI大模型正重构智能座舱研发体系的核心逻辑,需以场景认知为起点、混合架构为支柱、AI原生生态为落脚点。未来,研发体系需持续融合认知科学、边缘计算与开放生态理论,推动座舱从“工具”进化为“伙伴”。

我的专栏 1916

AD9361 RSSI配置实战:从寄存器到精准功率测量的避坑指南

本文详细解析了AD9361芯片的RSSI配置实战,从寄存器设置到精准功率测量的全流程避坑指南。通过优化模式选择、测量持续时间及高级参数配置,实现高精度信号强度测量,并分享实际项目中的校准流程与性能优化技巧,帮助工程师提升射频接收链路的测量精度。

weixin_38166557的博客 442

Pycharm 报错 Only SSH2 keys in OpenSSH format (DSA, RSA or ECDSA) or PuTTY Private Key *.ppk keys are

文章目录报错问题分析解决方案1. 把 id_rsa 转换成 PuTTY2. id_rsa 转换成 RSA参考 报错 在 Pycharm中 用密钥登录的时候会报错 [1/4/2021 10:54 AM] Upload to gpu11-188 failed: keypair ‘C:\Users\xx.ssh\id_rsa’ is corrupt or has unknown format. Only SSH2 keys in OpenSSH format (DSA, RSA or ECDSA) or PuT

月亮不知道的博客 2180

图像特征(一)——颜色特征(颜色直方图,颜色矩,颜色集,颜色聚合向量和颜色相关图)

本文主要是为了更好地理解图像特征,理解各方法的原理。转载请注明出处https://mp.youkuaiyun.com/console/editor/html/105090183 图像模式识别的一般步骤为:输入图像--图像预处理--特征提取--特征选择--图像分类--输出结果。 图像特征主要有:颜色特征、形状特征、纹理特征和空间关系特征。 本文主要介绍颜色特征,并给出matlab上实现的demo。 颜...

gloria_iris的博客 3万+

pycharm 密钥登录报错 Only SSH2 keys in OpenSSH format (DSA, RSA or ECDSA) or PuTTY Private Key *.ppk keys

Only SSH2 keys in OpenSSH format (DSA, RSA or ECDSA) or PuTTY Private Key *.ppk keys are supported.

xiaotoufa的博客 984

【AIGC】COT思维链:让AI学会拆解问题,像人一样思考

COT思维链的出现,为AI的发展开辟了一条新的道路。它让AI学会了像人类一样思考,将复杂问题分解成简单的步骤,并逐步推理出最终答案。希望我的引导会对你产生启发。

智兔唯新的博客 9002

AD(十四)调用已有的PCB元件封装库

软件:Altium Designer 16 需要资料:已有的PCB原理图文件(.PCBDOC)或者PCB库文件(.PCBLIB)(来源文中细说) 调用已有的PCB元件封装库(一)从已有的PCB原理图文件(*.PCBDOC)中调用1、PCB原理图文件来源2、打开已有的PCB原理图文件(*.PCBDOC)3、生成PCB封装库4、复制封装到工程文件下的PCB库文件(*.PCBLIB)5、重名问题(二)从已有的PCB库文件(*.PCBLIB)中调用1、PCB库文件(*.PCBLIB)的来源2、打开已有的PCB库 (

Curnane0_0的博客 5082

【实用攻略】手把手教你配置 SSH 免密登录(Windows + Linux)

本文介绍了如何配置Windows到Linux服务器的SSH公钥免密登录。首先在Windows使用ssh-keygen生成ed25519密钥对,然后将公钥上传到Linux服务器的~/.ssh/authorized_keys文件,并设置正确的权限(700和600)。接着配置Windows的SSH客户端config文件,指定密钥路径。最后讲解了VSCode的Remote-SSH插件配置方法,以及常见问题排查要点,包括权限设置检查和服务端日志查看。通过以上步骤,可实现一键SSH登录服务器,提高开发效率。

cjy_colorful0806的博客 1652

2.1 amdgpu BO的类型和用途

AMDGPU驱动中,amdgpu_bo_create_user和amdgpu_bo_create_kernel分别用于创建用户空间和内核空间的buffer对象(BO)。用户空间BO支持元数据、tiling flags等属性,由GEM handle管理生命周期;内核BO则用于驱动内部资源如ringbuffer,自动pin并可选CPU映射。二者在返回类型、生命周期管理和使用场景上存在根本差异,前者面向图形渲染/AI等应用,后者服务于驱动内部任务。

图形/计算GPU的驱动与虚拟化技术分享园地 2203

authorized_keys和authorized_keys2有什么不同?

authorized_keys和authorized_keys2有什么不同?SSHprotocols1.3和1.5使用 $HOME/.ssh/authorized_keysfile,SSHprotocol2.0使用 $HOME/.ssh/authorized_keys2file。在 OpenSSH version3以后,已经不赞成使用authorized_keys2了(虽然仍能用)。所有的公钥都应

Black-REN 2997

Claude Code Agents 进阶:多代理协作与任务委托

Agent 是一个独立运行的 Claude 实例,它有自己的上下文和任务焦点。│ 主 Claude ││ (协调者) ││ │ │▼ ▼ ▼│ 代码审查 │ │ 测试生成 │ │ 文档编写 ││ │ ││▼汇总结果,完成任务并行处理:多个 Agent 同时工作,提高效率任务隔离:每个 Agent 有独立的上下文专业分工:不同类型的 Agent 擅长不同任务灵活控制:可以指定运行模式、超时等参数。

gaoxiang_120的专栏 336

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

windows x86中ssh远程连接 ubuntu

本文介绍了2种windows x86架构电脑使用ssh方式远程连接到ubuntu系统的方法,1.通过windows控制台安装ssh工具,使用公钥对可免密连接;2.使用vs code安装ssh插件的方式连接到Ubuntu中。其中第二种比较简便。

LuDvei的博客 355

怀旧版电脑GBC模拟器

再现原版GBC掌机的界面,电脑运行连游戏界面都一样大小,很怀旧,很真实,(英文版)强烈推荐,很小的文件,很难才找到的。

【运维】两台Linux服务器SSH连接

输入 echo "你的公钥内容(把001的公钥粘贴到这里)" >> ~/.ssh/authorized_keys。输入 echo "你的公钥内容(把001的公钥粘贴到这里)" >> ~/.ssh/authorized_keys。3. 查看公钥内容并复制 例如公钥内容为:AAABBBCCC。2. 如果没有公钥则执行 生成公钥。3. 查看公钥并复制 公钥内容: AAABBBCCC。服务器A ----》 服务器B。5. 直连服务器002。1. 连接服务器002。5. 直连服务器002。

我是Superman丶的博客 765

计算机控制技术及应用

《计算机控制技术及应用》通过总结作者的科研成果和吸收国内外的先进理论、方法和技术,以计算机控制系统的网络化、开放化、智能化和集成化发展趋势为主线索,主要介绍计算机控制系统的基本概念和计算机控制系统的典型形式,计算机控制系统的数学描述与基本分析方法,以及数字PID控制器、最少拍控制系统、达林算法、状态变量设计法等设计方法及其各种改进算法。重点突出计算机控制系统输入输出通道接口的设计方法和典型控制系统的设计案例与实现方法等。

android 蓝牙通讯demo

android 下蓝牙通讯demo,实现了发现蓝牙,使能蓝牙,通过蓝牙发送消息。

Windows服务器是否可以使用SSH登录?

SSH是一种非常实用的网络协议,可以提高远程访问的安全性和便利性。在企业、科研、教育等领域,SSH被广泛应用于远程访问和管理计算机系统。

编程小风筝的博客 901

解决Home Assistant SSH集成连接Windows 11 OpenSSH服务器的问题

解决Home Assistant SSH集成连接Windows 11 OpenSSH服务器的问题 在使用Home Assistant的SSH集成功能连接Windows 11内置OpenSSH服务器时,用户可能会遇到"q must be exactly 160, 224, or 256 bits long"的错误提示。这个问题通常与密钥认证配置有关,下面将详细介绍解决方案。 问题...

gitblog_07697的博客 507

Windows 配置 SSH 免密登录 Linux 服务器

Windows 本机保存私钥Linux 服务器保存公钥生成密钥。id_rsa.pub即可实现免密登录。

m0_53162279的博客 366

Windows SSH免密登录Linux

user@linux_ip为linux服务器的登录用户和IP地址,例如dell@10.7.132.122,通过ipconfig命令查询。(需要ssh有ssh-copy-id命令,但是Win自带的 OpenSSH 通常没有 ssh-copy-id 命令)最后输入一次Linux登录密码即可,该命令与方法一的代码等价。默认在目录C:\Users\你的用户名.ssh。若不要求输入密码,则免密登录配置成功。

weixin_59801113的博客 96
上一篇: xming & putty
下一篇: SSH & auto login
jackie_gnu
博客等级 码龄16年 3粉丝 114原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值