The command looks like this: $ ssh -t "sudo yum install nano" Tunnel other applications Use this if sudo will challenge you for a password. If you need to elevate your privileges on the far side of the SSH connection with sudo, then force the use of a pseudo-terminal with -t. Note that it's likely you would use scp for this task (see below). Furthermore, you must compress the file: $ ssh "tar -czf /projects" > Or perhaps you need to pull a file from the remote system. You could try something like this: $ ssh "cat /var/log/secure" | grep -i fail Maybe you need to check a log file on a remote server for "fail" messages. The command executes, and the connection is closed.įor example, you could check the installation status of a package: $ ssh "rpm -qa | grep nano" SSH allows users to append the desired command directly to the connection attempt. Recall that you are challenged for a password in these examples unless you have key-based authentication configured (you probably should, but it's out of scope for this article). What if the only thing you need to do over the SSH connection is execute a single quick command? You might not want to take the separate actions of connecting and authenticating, running the command, and then disconnecting. The interactive session is established, and you may now conduct your administrative tasks. On some systems, security configurations prevent the root user from connecting over SSH, so it may be necessary to elevate privileges at this point. Once authenticated, the remote system presents a command prompt and provides the ability to run commands or access resources with whatever privileges the connecting user has. This is the password for the specified user account on the remote system. This command initiates SSH and specifies the user account the remote server should authenticate and the destination server's identity (hostname or IP address): $ ssh connection attempt triggers a password challenge. I'll begin with what might be considered a standard SSH connection. Read Passwordless SSH using public-private key pairs for guidance on this critical configuration or Eight ways to protect SSH access on your system for general suggestions. Key-based authentication connection attempts are quicker, easier to automate, and considered to be more secure.
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |