programing

PuTTY 세션목록을 내보내기 또는 Import하려면 어떻게 해야 합니까?

easyjava 2023. 4. 9. 22:29
반응형

PuTTY 세션목록을 내보내기 또는 Import하려면 어떻게 해야 합니까?

방법이 있을까요?

아니면 레지스트리에서 모든 기록을 수동으로 가져와야 하나요?

내보내기

cmd.exeregedit으로 인해 프롬프트가 높아야 합니다.

파일 " " " ( " " " )를 합니다)putty-sessions.reg( 화 : : ) 。

regedit /e "%USERPROFILE%\Desktop\putty-sessions.reg" HKEY_CURRENT_USER\Software\SimonTatham\PuTTY\Sessions

키를 한 모든 ssh 생성)putty.reg( 화 : : ) 。

regedit /e "%USERPROFILE%\Desktop\putty.reg" HKEY_CURRENT_USER\Software\SimonTatham

파워셸:

파일 " " " ( " " " )를 합니다)putty-sessions.reg( 화 : : ) 。

reg export HKCU\Software\SimonTatham\PuTTY\Sessions ([Environment]::GetFolderPath("Desktop") + "\putty-sessions.reg")

키를 한 모든 ssh 생성)putty.reg( 화 : : ) 。

reg export HKCU\Software\SimonTatham ([Environment]::GetFolderPath("Desktop") + "\putty.reg")

수입품

하다를 합니다.*.reg수입하다

대체 방법:

cmd.exe에는 고도의 명령어프롬프트가 필요해요

regedit /i putty-sessions.reg
regedit /i putty.reg

PowerShell:

reg import putty-sessions.reg
reg import putty.reg

주의: 교환하지 마십시오. SimonTatham사용자 이름을 지정합니다.

주의: 이러한 명령어는 관련된 SSH 키를 내보내지 않습니다.

다른 솔루션을 시도했을 때 다음 오류가 발생하였습니다.

Registry editing has been disabled by your administrator.

그럴 줄 알았어!

PuTTY 설정 내보내기 및 Import를 위한 아래 powershell 스크립트를 정리했습니다.내보낸 파일은 Windows .reg 파일이며 권한이 있는 경우 정상적으로 Import합니다.그렇지 않은 경우 import.ps1을 사용하여 로드합니다.

경고: 레지스트리를 이렇게 만지는 것은 Bad Idea™이며, 제가 무엇을 하고 있는지 잘 모르겠습니다.다음 스크립트를 자신의 책임으로 사용하여 IT부문이 머신의 이미지를 재작성하고 작업 내용에 대해 불편한 질문을 할 수 있도록 준비하십시오.

소스 시스템에서:

.\export.ps1

타깃 머신:

.\import.ps1 > cmd.ps1
# Examine cmd.ps1 to ensure it doesn't do anything nasty
.\cmd.ps1

export.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"

비이성코드 죄송합니다 파워셸에 대해 잘 모르거든요개선은 환영입니다!

  1. Run을 하고 Launch Run을 합니다.regedit 드롭
  2. 를 해 .HKEY_CURRENT_USER\Software\SimonTatham
  3. 아이콘마우스 오른쪽 버튼으로 하고 내보내기를 SimonTatham' 키(디렉토리 아이콘)를 마우스 오른쪽 버튼으로 클릭하고 내보내기를 선택합니다. ).putty.reg나중에 사용할 수 있도록 자신의 위치에 저장합니다.
  4. 레지스트리 에디터를 닫습니다.

다 했어요.

을 하는 PuTTY Portable.putty.regfilename을 클릭합니다.

이 .[path_to_Your_portable_apps]PuTTYPortable\Data\settings\putty.reg . 수입하다

오프라인 레지스트리 파일에서 Putty를 Import해야 하는 분들을 위해 예를 들어, 크래시된 시스템을 복구하거나 새 시스템으로 이동하여 이전 드라이브에서 데이터를 가져올 때 언급할 만한 솔루션이 하나 더 있습니다.

http://www.nirsoft.net/utils/registry_file_offline_export.html

이 훌륭한 무료 콘솔응용 프로그램은 레지스트리 전체 또는 특정 레지스트리 키만 내보냅니다.내 경우 레지스트리 파일을 오래된 드라이브에서 내보내기 도구와 동일한 디렉터리로 복사한 다음 관리자로 실행되는 CMD 창에서 다음 명령과 구문을 사용했습니다.

RegFileExport.exe NTUSER.DAT putty.reg "HKEY_CURRENT_USER\Software\"사이먼 태텀

.reg 파일을 Import하고 Putty를 시작하면 모든 것이 표시됩니다.심플하고 효율적입니다.

레지스트리를 조작하고 싶지 않은 분들을 위해 파일에 저장하는 퍼티의 변형을 만들었습니다.다음 URL에 있습니다.http://jakub.kotrla.net/putty/

퍼티 팀이 이것을 메인 유통의 옵션으로 채택해 주었으면 합니다.

이는 위에서 설명한 것보다 훨씬 쉽게 레지스트리 내보내기를 가져올 수 있습니다. + 단순:

  1. 파일을 오른쪽 클릭하여
  2. "Merge"를 선택합니다.

윈7 프로 챔피언처럼 일했어

m0nhawk의 답변은 Windows 10에서는 작동하지 않았습니다.높은 명령 프롬프트가 필요했고 파일 전송을 거부했습니다.

이 방법은 작동했고 상승이 필요하지 않았습니다.

reg export HKEY_CURRENT_USER\Software\SimonTatham\PuTTY putty.reg

§:
어떤 계정으로 퍼티 및 를 들어, 새로운 세션.

★★★★★★★★★★★★★★★★★★:
키 - 오래된 계정에서 레지스트리 키 내보내기 -
- 에서 새 키 - - --------------------------------- 。

내보내기 레지스트리 키: (구 계정에서)

  1. OLD 계정에 로그인합니다(예: Tomold).
  2. 일반 '명령 프롬프트' 열기(관리자 아님!)
  3. 'regedit' 입력
  4. 설정이 저장되어 있는 레지스트리 섹션([HKEY_CURRENT_USER\SOFTWARE\SimonTatham] 등)으로 이동하여 클릭합니다.
  5. 파일 메뉴에서 '내보내기'를 선택하거나 마우스 오른쪽 버튼을 클릭합니다(Ctrl 'selected branch'를 누름).
  6. 파일에 저장하고 이름을 지정합니다(예: 'puttyconfig.reg').
  7. 다시 로그아웃

가져오기 레지스트리 키: (새로운 계정으로)

  1. 새 계정에 로그인합니다(예: Tom).

  2. 일반 '명령 프롬프트' 열기(관리자 아님!)

  3. 'regedit' 입력

  4. 메뉴에서 '가져오기'를 선택합니다.

  5. 가져올 레지스트리 파일(예: 'puttyconfig.reg')을 선택합니다.

  6. 다 했어요.


「 「 HKEY _ CURRENT _ USER ... 」 。「 admin 」 。또한 regedit은 admin으로 실행되며 admin-user에게는 해당 섹션이 표시되며 사용자가 전송원 또는 전송처로 표시되지 않습니다.

저처럼 새 Windows를 설치하고 퍼티 세션에 대해 기억한 에만 오래된 Windows 하드 드라이브 또는 적어도 오래된 "홈" 디렉토리가 백업된 경우에도 가져올 수 있습니다.C:\Users\<user_name>).

이 디렉토리에는 다음과 같은 것이 있습니다.NTUSER.DAT기본적으로 숨겨져 있으므로 Windows 탐색기에서 숨겨진 파일을 활성화하거나 다른 파일 브라우저를 사용해야 합니다.이 파일에는HKEY_CURRENT_USER오래된 Windows 레지스트리의 브랜치.

사용하기 위해서는 열어야 합니다.regedit새 Windows에서 를 선택합니다.HKEY_USERS열쇠.

그럼 선택해주세요File->Load Hive...오래된 Windows 인스톨의 「홈」디렉토리를 검색합니다.이 디렉토리에는 다음과 같은 것이 있습니다.NTUSER.DAT이 파일은 기본적으로 숨겨져 있기 때문에 Windows 탐색기 속성에서 숨겨진 파일을 표시할 수 있도록 설정하지 않은 경우 파일 이름을 수동으로 입력할 수 있습니다.File name[ Load Hive 로드 대화상자의 입력 상자를 누릅니다.그런 다음 다음 대화창에 오래된 레지스트리를 로드할 키 이름을 입력합니다.tmp.

레지스트리는 전전 your your your your your your your your 。HKEY_CURRENT_USER 할 수 .HKEY_USERS\tmp현재 레지스트리의 브랜치.

" " " 를 내보냅니다.HKEY_USERS\tmp\Software\SimonTatham로 분기하다putty.reg이, 모든 「」, 「」, 「」, 「」의 을 실시합니다.HKEY_USERS\tmp로 묶다.HKEY_CURRENT_USER 이제 을 .regfilename을 클릭합니다.

이 파일을 더블 클릭하면, 현재의 Windows 레지스트리로 Import 할 수 있습니다.m0nhawk의 답변을 참조하십시오.

[ ]를 합니다.HKEY_USERS\tmp 를 선택하고 , 「」를 선택합니다.File->Unload Hive...을 사용하다

PuTTY portable.

단순히 내보내기 이동putty.reg 사용)에서 (m0nhawk 용액 사용)로PuTTYPortable\Data\settings\을 새로 .PuTTY Portable은 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. 모든 세션 삭제
  4. 새 .reg를 Import합니다.

여기서 발췌 : http://www.sysadmit.com/2015/11/putty-exportar-configuracion.html

ratil.life/first-useful-powershell-script-putty-to-ssh-config에 PowerShell 스크립트가 있습니다.이 스크립트는 세션을 다음에서 사용할 수 있는 형식으로 변환할 수 있습니다..ssh/configGitHub에서도 볼 수 있습니다.

이 발췌문에는 코드의 주요 내용이 포함되어 있으며, 그 결과 생성된 설정을 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 }
    }

}

세션 데이터베이스를 작성할 때 putty connection manager를 사용합니다.그 데이터베이스를 복사하여 다른 컴퓨터로 쉽게 가져올 수 있습니다.

이 편리한 가이드를 참조하십시오.

언급URL : https://stackoverflow.com/questions/13023920/how-to-export-import-putty-sessions-list

반응형