windows 如何导出/导入 PuTTy 会话列表?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/13023920/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to export/import PuTTy sessions list?
提问by s.webbandit
Is there a way to do this?
有没有办法做到这一点?
Or I have to take manually every record from Registry?
或者我必须手动从注册表中获取每条记录?
回答by m0nhawk
Export
出口
cmd.exe
, requireelevated prompt:
cmd.exe
,需要提升提示:
Only sessions:
仅会话:
regedit /e "%USERPROFILE%\Desktop\putty-sessions.reg" HKEY_CURRENT_USER\Software\SimonTatham\PuTTY\Sessions
All settings:
所有设置:
regedit /e "%USERPROFILE%\Desktop\putty.reg" HKEY_CURRENT_USER\Software\SimonTatham
Powershell:
电源外壳:
Only sessions:
仅会话:
reg export HKCU\Software\SimonTatham\PuTTY\Sessions ([Environment]::GetFolderPath("Desktop") + "\putty-sessions.reg")
All settings:
所有设置:
reg export HKCU\Software\SimonTatham ([Environment]::GetFolderPath("Desktop") + "\putty.reg")
Import
进口
Double-click on the *.reg
file and accept the import.
双击*.reg
文件并接受导入。
Alternative ways:
替代方法:
cmd.exe
, requireelevated command prompt:
cmd.exe
,需要提升的命令提示符:
regedit /i putty-sessions.reg
regedit /i putty.reg
PowerShell:
电源外壳:
reg import putty-sessions.reg
reg import putty.reg
Note: do not replaceSimonTatham
with your username.
注意:不要替换SimonTatham
为您的用户名。
Note: It will create a reg
file on the Desktop of the current user.
注意:它将reg
在当前用户的桌面上创建一个文件。
Note: It will notexport related SSH keys.
注意:它不会导出相关的 SSH 密钥。
回答by dwurf
When I tried the other solutions I got this error:
当我尝试其他解决方案时,出现此错误:
Registry editing has been disabled by your administrator.
Phooey to that, I say!
Phooey,我说!
I put together the below powershell scripts for exporting and importing PuTTY settings. The exported file is a windows .reg file and will import cleanly if you have permission, otherwise use import.ps1 to load it.
我将以下 powershell 脚本放在一起,用于导出和导入 PuTTY 设置。导出的文件是 windows .reg 文件,如果您有权限,将干净地导入,否则使用 import.ps1 加载它。
Warning: messing with the registry like this is a Bad Idea?, and I don't really know what I'm doing. Use the below scripts at your own risk, and be prepared to have your IT department re-image your machine and ask you uncomfortable questions about what you were doing.
警告:像这样弄乱注册表是个坏主意吗?,我真的不知道我在做什么。使用以下脚本的风险由您自担,并准备好让您的 IT 部门重新映像您的机器,并询问您有关您在做什么的问题。
On the source machine:
在源机器上:
.\export.ps1
On the target machine:
在目标机器上:
.\import.ps1 > cmd.ps1
# Examine cmd.ps1 to ensure it doesn't do anything nasty
.\cmd.ps1
export.ps1
导出.ps1
# All settings
$registry_path = "HKCU:\Software\SimonTatham"
# Only sessions
#$registry_path = "HKCU:\Software\SimonTatham\PuTTY\Sessions"
$output_file = "putty.reg"
$registry = ls "$registry_path" -Recurse
"Windows Registry Editor Version 5.00" | Out-File putty.reg
"" | Out-File putty.reg -Append
foreach ($reg in $registry) {
"[$reg]" | Out-File putty.reg -Append
foreach ($prop in $reg.property) {
$propval = $reg.GetValue($prop)
if ("".GetType().Equals($propval.GetType())) {
'"' + "$prop" + '"' + "=" + '"' + "$propval" + '"' | Out-File putty.reg -Append
} elseif ($propval -is [int]) {
$hex = "{0:x8}" -f $propval
'"' + "$prop" + '"' + "=dword:" + $hex | Out-File putty.reg -Append
}
}
"" | Out-File putty.reg -Append
}
import.ps1
导入.ps1
$input_file = "putty.reg"
$content = Get-Content "$input_file"
"Push-Location"
"cd HKCU:\"
foreach ($line in $content) {
If ($line.StartsWith("Windows Registry Editor")) {
# Ignore the header
} ElseIf ($line.startswith("[")) {
$section = $line.Trim().Trim('[', ']')
'New-Item -Path "' + $section + '" -Force' | %{ $_ -replace 'HKEY_CURRENT_USER\', '' }
} ElseIf ($line.startswith('"')) {
$linesplit = $line.split('=', 2)
$key = $linesplit[0].Trim('"')
if ($linesplit[1].StartsWith('"')) {
$value = $linesplit[1].Trim().Trim('"')
} ElseIf ($linesplit[1].StartsWith('dword:')) {
$value = [Int32]('0x' + $linesplit[1].Trim().Split(':', 2)[1])
'New-ItemProperty "' + $section + '" "' + $key + '" -PropertyType dword -Force' | %{ $_ -replace 'HKEY_CURRENT_USER\', '' }
} Else {
Write-Host "Error: unknown property type: $linesplit[1]"
exit
}
'Set-ItemProperty -Path "' + $section + '" -Name "' + $key + '" -Value "' + $value + '"' | %{ $_ -replace 'HKEY_CURRENT_USER\', '' }
}
}
"Pop-Location"
Apologies for the non-idiomatic code, I'm not very familiar with Powershell. Improvements are welcome!
为非惯用代码道歉,我对 Powershell 不是很熟悉。欢迎改进!
回答by Sireesh Yarlagadda
Launch Run, then type in the Open drop down window: regedit
Navigate to, just like in Window's Explorer:
HKEY_CURRENT_USER\Software\SimonTatham- Right click on 'SimonTatham' key (directory icon), select Export
Give the file a name (say) putty.reg and save it to your location for
later use. - Close Registry Editor.
启动运行,然后在打开下拉窗口中输入:regedit
导航到,就像在 Window 的资源管理器中一样:
HKEY_CURRENT_USER\Software\SimonTatham- 右键单击“SimonTatham”键(目录图标),选择“导出”
为文件命名(例如) putty.reg 并将其保存到您的位置以备
后用。 - 关闭注册表编辑器。
Done.
完毕。
回答by bumerang
If You want to import settings on PuTTY Portable
You can use the putty.reg
file.
如果您想导入设置,PuTTY Portable
您可以使用该 putty.reg
文件。
Just put it to this path [path_to_Your_portable_apps]PuTTYPortable\Data\settings\putty.reg
. Program will import it
只要把它放到这条路径上[path_to_Your_portable_apps]PuTTYPortable\Data\settings\putty.reg
。程序将导入它
回答by monsune
For those of you who need to import Putty from offline registry file e.g. when you are recovering from crashed system or simply moving to a new machine and grabbing data off that old drive there is one more solution worth mentioning:
对于那些需要从离线注册表文件导入 Putty 的人,例如当您从崩溃的系统中恢复或只是移动到一台新机器并从旧驱动器中获取数据时,还有一个值得一提的解决方案:
http://www.nirsoft.net/utils/registry_file_offline_export.html
http://www.nirsoft.net/utils/registry_file_offline_export.html
This great and free console application will export the entire registry or only a specific registry key. In my case i simply copied the registry file from an old drive to the same directory as the exporter tool and then i used following command and syntax in CMD window run as administrator:
这个伟大且免费的控制台应用程序将导出整个注册表或仅导出特定的注册表项。在我的情况下,我只是将注册表文件从旧驱动器复制到导出工具所在的目录,然后在以管理员身份运行的 CMD 窗口中使用以下命令和语法:
RegFileExport.exe NTUSER.DAT putty.reg "HKEY_CURRENT_USER\Software\SimonTatham"
RegFileExport.exe NTUSER.DAT putty.reg "HKEY_CURRENT_USER\Software\SimonTatham"
After importing the .reg file and starting Putty everything was there. Simple and efficient.
导入 .reg 文件并启动 Putty 后,一切都在那里。简单高效。
回答by DudeGoingDeaf
This was so much easier importing the registry export than what is stated above. + Simply:
这比上面所说的更容易导入注册表导出。+ 简单:
- right click on the file and
- select "Merge"
- 右键单击该文件,然后
- 选择“合并”
Worked like a champ on Win 7 Pro.
在 Win 7 Pro 上像冠军一样工作。
回答by Jason K.
For those who don't want to mess with the registry, a variation of putty that saves to file has been created. It is located here: http://jakub.kotrla.net/putty/
对于那些不想弄乱注册表的人,已经创建了保存到文件的腻子的变体。它位于这里:http: //jakub.kotrla.net/putty/
It would be nice if the putty team would take this as an option into the main distribution.
如果腻子团队将其作为主要发行版的一个选项,那就太好了。
回答by Mungo
Example:
How to transfer putty configuration and session configuration from one user account to another e.g. when created a new account and want to use the putty sessions/configurations from the old account
示例:
如何将 putty 配置和会话配置从一个用户帐户转移到另一个用户帐户,例如,当创建一个新帐户并希望使用旧帐户中的 putty 会话/配置时
Process:
- Export registry key from old account into a file
- Import registry key from file into new account
过程:
- 将旧帐户中的注册表项导出到文件中
-将文件中的注册表项导入到新帐户中
Export reg key:(from OLD account)
导出 reg 密钥:(来自 OLD 帐户)
- Login into the OLD account e.g. tomold
- Open normal 'command prompt' (NOT admin !)
- Type 'regedit'
- Navigate to registry section where the configuration is being stored e.g. [HKEY_CURRENT_USER\SOFTWARE\SimonTatham] and click on it
- Select 'Export' from the file menu or right mouse click (radio ctrl 'selected branch')
- Save into file and name it e.g. 'puttyconfig.reg'
- Logout again
- 登录旧帐户,例如 tomold
- 打开普通的“命令提示符”(不是管理员!)
- 输入“regedit”
- 导航到存储配置的注册表部分,例如 [HKEY_CURRENT_USER\SOFTWARE\SimonTatham] 并单击它
- 从文件菜单中选择“导出”或鼠标右键单击(radio ctrl 'selected branch')
- 保存到文件中并将其命名为例如“puttyconfig.reg”
- 再次登出
Import reg key:(into NEW account)
导入注册密钥:(到新帐户)
Login into NEW account e.g. tom
Open normal 'command prompt' (NOT admin !)
Type 'regedit'
Select 'Import' from the menu
Select the registry file to import e.g. 'puttyconfig.reg'
Done
登录新帐户,例如 tom
打开普通的“命令提示符”(不是管理员!)
输入“regedit”
从菜单中选择“导入”
选择要导入的注册表文件,例如“puttyconfig.reg”
完毕
Note:
Do not use an 'admin command prompt' as settings are located under '[HKEY_CURRENT_USER...] 'and regedit would run as admin and show that section for the admin-user rather then for the user to transfer from and/or to.
注意:
请勿使用“管理员命令提示符”,因为设置位于“[HKEY_CURRENT_USER...]”下,并且 regedit 将以管理员身份运行并为管理员用户显示该部分,而不是让用户从中传输和/或到。
回答by L. G.
An improvement to the solution of bumerang to import data to PuTTY portable
.
对 bumerang 导入数据的解决方案的改进PuTTY portable
。
Simply moving exported putty.reg
(with m0nhawk solution) to PuTTYPortable\Data\settings\
didn't work. PuTTY Portable backup the file and create a new empty one.
简单地将导出putty.reg
(使用 m0nhawk 解决方案)移动到PuTTYPortable\Data\settings\
不起作用。PuTTY Portable 备份文件并创建一个新的空文件。
To workaround this issue, merge both putty.reg
copying manually the config you want to migrate from your exported putty.reg
to the newly created PuTTYPortable\Data\settings\putty.reg
below following lines.
要解决此问题,putty.reg
请putty.reg
在PuTTYPortable\Data\settings\putty.reg
以下几行中手动合并要从导出的配置迁移到新创建的配置的复制。
REGEDIT4
[HKEY_CURRENT_USER\Software\SimonTatham\PuTTY]
"RandSeedFile"="D:\Programme\PuTTYPortable\Data\settings\PUTTY.RND"
回答by Meow
The answer posted by @m0nhawk doesn't seem to work as I test on a Windows 7 machine. Instead, using the following scripts would export/import the settings of putty:
当我在 Windows 7 机器上测试时,@m0nhawk 发布的答案似乎不起作用。相反,使用以下脚本将导出/导入 putty 的设置:
::export
@echo off
set regfile=putty.reg
pushd %~dp0
reg export HKCU\Software\SimonTatham %regfile% /y
popd
--
——
::import
@echo off
pushd %~dp0
set regfile=putty.reg
if exist %regfile% reg import %regfile%
popd