有什么办法可以做到这一点?
还是我必须手动从注册表中提取每条记录?
只有会话。
regedit /e "%USERPROFILE%\Desktop\putty-sessions.reg" HKEY_CURRENT_USER\Software\SimonTatham\PuTTY\Sessions
所有设置。
regedit /e "%USERPROFILE%\Desktop\putty.reg" HKEY_CURRENT_USER\Software\SimonTatham
只有会话。
reg export HKCU\Software\SimonTatham\PuTTY\Sessions ([Environment]::GetFolderPath("Desktop") + "\putty-sessions.reg")
所有设置。
reg export HKCU\Software\SimonTatham ([Environment]::GetFolderPath("Desktop") + "\putty.reg")
双击*.reg
文件,接受导入。
cmd.exe
, 需要升高的命令提示。regedit /i putty-sessions.reg
regedit /i putty.reg
reg import putty-sessions.reg
reg import putty.reg
注意:不要用你的用户名替换 SimonTatham
。
注意:它将在当前用户的桌面上创建一个reg
文件。
注意:它不会***导出相关的SSH密钥。
当我尝试其他的解决方案时,我得到了这个错误。
Registry editing has been disabled by your administrator.
我说,Phooey to that!
我整理了下面的powershell脚本用于导出和导入PuTTY设置。 导出的文件是一个windows的.reg文件,如果你有权限的话,会很干净地导入,否则使用import.ps1来加载它。
警告。 乱用注册表是一个坏主意™,我真的不知道我在做什么。 使用下面的脚本,风险自负,并准备好让你的IT部门重新映像你的机器,并问你一些关于你所做的不舒服的问题。
在源机器上。
.\export.ps1
在目标机器上,
.\import.ps1 > cmd.ps1
# Examine cmd.ps1 to ensure it doesn't do anything nasty
.\cmd.ps1
。
.\import.ps1 > cmd.ps1
# Examine cmd.ps1 to ensure it doesn't do anything nasty
.\cmd.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
$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"
抱歉代码不规范,我'对Powershell不是很熟悉。 欢迎改进!
1、发射运行。 然后在 "打开 "下拉窗口中输入。 regedit
右键点击'SimonTatham'。 键(目录图标),选择导出 给文件取个名字(比如说)putty.reg,并保存到你的位置,以便于 以后使用。
关闭注册表编辑器。
完成。
对于那些需要从离线注册表文件中导入Putty的人,例如:当你从崩溃的系统中恢复时,或者只是简单地移动到新的机器上,并从旧的驱动器上抓取数据时,还有一个值得一提的解决方案。 当你从崩溃的系统中恢复,或者仅仅是移动到一个新的机器并从旧的驱动器上抓取数据时,还有一个值得一提的解决方案。
http://www.nirsoft.net/utils/registry_file_offline_export.html
这个伟大而免费的控制台应用程序将导出整个注册表或只导出一个特定的注册表键。 在我的例子中,我只是简单地将注册表文件从旧的驱动器复制到与导出工具相同的目录中,然后我在CMD窗口中使用以下命令和语法以管理员身份运行。
RegFileExport.exe NTUSER.DAT putty.reg "HKEY_CURRENT_USER/Software/SimonTatham"
导入.reg文件后,启动Putty一切都在那里。 简单高效。
这比上面所说的导入注册表导出要简单得多。
选择"合并"。
在Win 7 Pro上工作得很好。
对于那些不想搞乱注册表的人,已经创建了一个保存到文件的腻子的变体。 它位于这里。 http://jakub.kotrla.net/putty/
如果腻子团队能把这个作为一个选项加入到主发行版中,那就更好了。
例:<br>。 如何将putty配置和会话配置从一个用户账户转移到另一个用户账户,例如:当创建了一个新账户,并想使用旧账户的putty会话/配置时。 当创建了一个新的账户,并想使用旧账户的putty会话/配置时。
流程:
导出注册密钥: (来自OLD账户)
打开正常的'命令提示符&39。 (不是admin !)
输入 'regedit'。
導覽到儲存配置的註冊表部分,例如: [HKEY_CURRENT_USER/SOFTWARE/SimonT]。 HKEY_CURRENT_USER/SOFTWARE/SimonTatham]并点击它。
从文件菜单中选择'导出'。 从文件菜单或鼠标右键单击(单选ctrl '选定分支')。
保存到文件中,并将其命名为例如 'puttyconfig.reg'。 7.再次登出
导入注册密钥: (进入新账户)
登录到新账户,例如 例如
打开正常的'命令提示符&39。 (不是admin !)
输入'regedit'。
从菜单中选择 '导入' 从菜单中选择'导入
选择要导入的注册表文件,如 'puttyconfig.reg'。
13.完成
注意:<br>.不要使用'管理员命令提示符'。 不要使用'管理命令提示符'。 因为设置位于'[HKEY_CURRENT_USER/...] '下,regedit将以管理员身份运行,并为管理员用户显示该部分,而不是为用户传输和/或到。
对bumerang的解决方案的改进,将数据导入到PuTTY portable
。
简单地将导出的putty.reg
(用m0nhawk的方案)移到PuTTYPortable/Data/settings
中并不工作。PuTTY Portable备份了该文件并创建了一个新的空文件。
为了解决这个问题,合并两个putty.reg
,手动复制你想从导出的putty.reg
中迁移的配置到新创建的PuTTYPortable/Data\settings/putty.reg
下面的行。
REGEDIT4
[HKEY_CURRENT_USER\Software\SimonTatham\PuTTY]
"RandSeedFile"="D:\\Programme\\PuTTYPortable\\Data\\settings\\PUTTY.RND"
由@m0nhawk发布的答案似乎不工作,因为我在Windows 7机器上测试。 相反,使用以下脚本可以导出/导入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
使用这种方法还可以进行大规模的配置更改,比如更改所有会话的字体。
1.导出到.reg 2. 对.reg进行搜索和替换。 3. 3. 删除所有会议 4. 导入新的.reg
摘自此处。 [http://www.sysadmit.com/2015/11/putty-exportar-configuracion.html][1]
[1]: http://www.sysadmit.com/2015/11/putty-exportar-configuracion.html
我使用[putty连接管理器][1],在这里你可以创建一个会话数据库。 它很容易复制和导入该数据库到其他计算机。
请看这个[方便的指南][2] 。
[1]: http://www.thegeekstuff.com/scripts/puttycm.zip [2]: http://www.thegeekstuff.com/2009/03/putty-extreme-makeover-using-putty-connection-manager/
在[ratil.life/first-useful-powershell-script-putty-to-ssh-config][2]中有一个PowerShell脚本,它可以将会话转换为可用于.ssh/config
的格式。
它也可以在[GitHub][1]上找到。
这段摘录包含了代码的主要内容,并会直接将生成的 config 打印到 stdout 中。
# Registry path to PuTTY configured profiles
$regPath = 'HKCU:\SOFTWARE\SimonTatham\PuTTY\Sessions'
# Iterate over each PuTTY profile
Get-ChildItem $regPath -Name | ForEach-Object {
# Check if SSH config
if (((Get-ItemProperty -Path "$regPath\$_").Protocol) -eq 'ssh') {
# Write the Host for easy SSH use
$host_nospace = $_.replace('%20', $SpaceChar)
$hostLine = "Host $host_nospace"
# Parse Hostname for special use cases (Bastion) to create SSH hostname
$puttyHostname = (Get-ItemProperty -Path "$regPath\$_").HostName
if ($puttyHostname -like '*@*') {
$sshHostname = $puttyHostname.split("@")[-1]
}
else { $sshHostname = $puttyHostname }
$hostnameLine = "`tHostName $sshHostname"
# Parse Hostname for special cases (Bastion) to create User
if ($puttyHostname -like '*@*') {
$sshUser = $puttyHostname.split("@")[0..($puttyHostname.split('@').length - 2)] -join '@'
}
else { $sshHostname = $puttyHostname }
$userLine = "`tUser $sshUser"
# Parse for Identity File
$puttyKeyfile = (Get-ItemProperty -Path "$regPath\$_").PublicKeyFile
if ($puttyKeyfile) {
$sshKeyfile = $puttyKeyfile.replace('\', '/')
if ($prefix) { $sshKeyfile = $sshKeyfile.replace('C:', $prefix) }
$identityLine = "`tIdentityFile $sshKeyfile"
}
# Parse Configured Tunnels
$puttyTunnels = (Get-ItemProperty -Path "$regPath\$_").PortForwardings
if ($puttyTunnels) {
$puttyTunnels.split() | ForEach-Object {
# First character denotes tunnel type
$tunnelType = $_.Substring(0,1)
# Digits follow tunnel type is local port
$tunnelPort = $_ -match '\d*\d(?==)' | Foreach {$Matches[0]}
# Text after '=' is the tunnel destination
$tunnelDest = $_.split('=')[1]
if ($tunnelType -eq 'D') {
$tunnelLine = "`tDynamicForward $tunnelPort $tunnelDest"
}
ElseIf ($tunnelType -eq 'R') {
$tunnelLine = "`tRemoteForward $tunnelPort $tunnelDest"
}
ElseIf ($tunnelType -eq 'L') {
$tunnelLine = "`tLocalForward $tunnelPort $tunnelDest"
}
}
# Parse if Forward Agent is required
$puttyAgent = (Get-ItemProperty -Path "$regPath\$_").AgentFwd
if ($puttyAgent -eq 1) { $agentLine = "`tForwardAgent yes" }
# Parse if non-default port
$puttyPort = (Get-ItemProperty -Path "$regPath\$_").PortNumber
if (-Not $puttyPort -eq 22) { $PortLine = "`tPort $puttyPort" }
}
# Build output string
$output = "$hostLine`n$hostnameLine`n$userLine`n$identityLine`n$tunnelLine`n$agentLine`n"
# Output to file if set, otherwise STDOUT
if ($outfile) { $output | Out-File $outfile -Append}
else { Write-Host $output }
}
}
[1]: https://github.com/tmsteen/PowerShell-Scripts/blob/master/PuTTY_to_SSH_config.ps1 [2]: https://ratil.life/first-useful-powershell-script-putty-to-ssh-config/
如果你和我一样,安装了新的Windows,并且在**后才想起putty会话,你仍然可以导入它们,如果你有旧的Windows硬盘或者至少你的旧的"home".目录备份(C:\Users\<user_name>``)。 目录备份(
C:/\Users/lt;user_name>`)。
在这个目录下应该有NTUSER.DAT
文件。
它默认是隐藏的,所以你应该在你的Windows资源管理器中启用隐藏文件或使用其他文件浏览器。
这个文件包含了旧版Windows注册表的HKEY_CURRENT_USER
分支。
要使用它,你需要在新的Windows上打开 "regedit",并选择 "HKEY_USERS "键。
然后选择文件
->
Load Hive...
,然后找到你旧Windows安装的"home"
目录的旧Windows安装目录。
在这个目录中应该有NTUSER.DAT
文件。
它默认是隐藏的,所以,如果你没有在你的Windows资源管理器属性中启用显示隐藏的文件,那么你可以在"Load Hive".对话框的文件名
输入框中手动输入文件名,然后按<kbd;键。
对话框中输入文件名,然后按Enter。
然后在下一个对话框窗口中输入一些键名,将旧的注册表载入其中。
例如
tmp
。
你的旧注册表的HKEY_CURRENT_USER
分支现在应该可以在当前注册表的HKEY_USERS/tmp
分支下访问。
现在将HKEY_USERS/tmp/Software/SimonTatham
分支导出到putty.reg
文件中,在你喜欢的文本编辑器中打开这个文件,并将所有HKEY_USERS/tmp
字符串找到并替换为HKEY_CURRENT_USER
。
现在保存.reg
文件。
你可以通过双击这个文件导入到你当前的Windows注册表中。 参见m0nhawk'的回答如何做到这一点。
最后,在注册表编辑器中选择HKEY_USERS/tmp
分支,然后选择File
->
Unload Hive...
,然后确认这个操作。