HPE GreenLake Administration
- Community Home
 - >
 - Servers and Operating Systems
 - >
 - Operating Systems
 - >
 - Operating System - HP-UX
 - >
 - Re: Use ssh in a script
 
Operating System - HP-UX
        1840147
        Members
    
    
        4438
        Online
    
    
        110161
        Solutions
    
Forums
        Categories
Company
Local Language
                
                  
                  back
                
        
                
        
                
        
                
        
        
        
                
        
                
        
        
        
                
        
              
              Forums
Discussions
Forums
- Data Protection and Retention
 - Entry Storage Systems
 - Legacy
 - Midrange and Enterprise Storage
 - Storage Networking
 - HPE Nimble Storage
 
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
                
                  
                  back
                
            
                
            
                
            
                
            
                
            
                
            
                
            
                
            
                
            
                
            
                
            
                
            
                
            
                
            
                
            
                
            
                
            
            
                
            
                
            
                
            
                
            
            
                
            
                
            
            
                
            
                
              
            Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
 - Appliance Servers
 - Alpha Servers
 - BackOffice Products
 - Internet Products
 - HPE 9000 and HPE e3000 Servers
 - Networking
 - Netservers
 - Secure OS Software for Linux
 - Server Management (Insight Manager 7)
 - Windows Server 2003
 - Operating System - Tru64 Unix
 - ProLiant Deployment and Provisioning
 - Linux-Based Community / Regional
 - Microsoft System Center Integration
 
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Blogs
        Information
        Community
Resources
Community Language
        Language
        Forums
Blogs
	
		
			
            
                
            Go to solution
        
            
		
		
			
            	
	
		
        
		
	
	
		Topic Options
			
				
					
	
			
		
	- Subscribe to RSS Feed
 - Mark Topic as New
 - Mark Topic as Read
 - Float this Topic for Current User
 - Bookmark
 - Subscribe
 - Printer Friendly Page
 
- Mark as New
 - Bookmark
 - Subscribe
 - Mute
 - Subscribe to RSS Feed
 - Permalink
 - Report Inappropriate Content
 
03-13-2001 09:23 AM
03-13-2001 09:23 AM
			
				
					
					
						Hi,
How can I set a ssh key to allow user to use ssh in a script without asking for password?
Thank you.
June
	
			
				
		
			
			
			
			
			
			
		
		
		
	
	
	
How can I set a ssh key to allow user to use ssh in a script without asking for password?
Thank you.
June
Solved! Go to Solution.
		1 REPLY 1
	
	            
            
		
		
			
            
                - Mark as New
 - Bookmark
 - Subscribe
 - Mute
 - Subscribe to RSS Feed
 - Permalink
 - Report Inappropriate Content
 
03-13-2001 11:23 AM
03-13-2001 11:23 AM
Solution
			
				
					
					
						You'll need to make sure that RSA authentication is enabled in your sshd_config
1. Login as the user and generate a keypair using ssh-keygen. You can use a null passphrase, but I don't recommend it.
2. Add the contents of the $HOME/.ssh/identity.pub file to the $HOME/.ssh/authorized_keys file on all machines where you wish to log in using RSA authentication.
3. If you don't use a null passphrase then to execute your script, write a small wrapper script which uses ssh-agent to launch your script. 'ssh-agent myscript'
4. Your script will contain something like the following:
#!/bin/sh
#
# myscript --- does stuff
# This script is running in the shell launched with ssh-agent
# Load the passphrase into memory
cat .passphrase |ssh-add -p
ssh 
Carefully review all the man pages on the ssh commands. 
					
				
			
			
				
		
		
	
	
	
1. Login as the user and generate a keypair using ssh-keygen. You can use a null passphrase, but I don't recommend it.
2. Add the contents of the $HOME/.ssh/identity.pub file to the $HOME/.ssh/authorized_keys file on all machines where you wish to log in using RSA authentication.
3. If you don't use a null passphrase then to execute your script, write a small wrapper script which uses ssh-agent to launch your script. 'ssh-agent myscript'
4. Your script will contain something like the following:
#!/bin/sh
#
# myscript --- does stuff
# This script is running in the shell launched with ssh-agent
# Load the passphrase into memory
cat .passphrase |ssh-add -p
ssh
Carefully review all the man pages on the ssh commands.
	Remember, wherever you go, there you are...
			
			
				
			
			
			
			
			
			
		The opinions expressed above are the personal opinions of the authors, not of Hewlett Packard Enterprise. By using this site, you accept the Terms of Use and Rules of Participation.
		
	
	
Company
Events and news
Customer resources
© Copyright 2025 Hewlett Packard Enterprise Development LP